Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding additional assets to the queue after loadQueue is triggered #71

Open
digitalbreed opened this issue Jul 27, 2020 · 3 comments

Comments

@digitalbreed
Copy link

Is your feature request related to a problem? Please describe.
I was investigating how loading of a Tiled map (tmx) could work in Black. tmx files are XML which contains references to additional files, like tilesets (tsx) or images, and tilesets are also XML which lists images. This means that additional resources which need to be queued for loading are only known after the map file was loaded and parsed.

Describe the solution you'd like
Assets should be able to queue additional assets while loading, for example by having access to the AssetManager from which they're being loaded. Currently the AssetManager would have to be passed in manually, but queuing while loading is currently denied due to an invalid state of the AssetManager.

Additional context
Tiled is a popular 2D map editor and importing Tiled files should be supported. I'd love to hear alternative approaches to deal with nested loading of assets.

@745comics
Copy link
Contributor

Have you considered using another instance of AssetManager to load additional assets? Black.assets is just a default instance. new AssetManager() should do the trick.

@digitalbreed
Copy link
Author

Thanks @745comics, I tried and it works for me. I just need to make sure the top-level asset's ready call is delayed until all other "child" assets are loaded through a separate AssetManager.
But that's not an ideal solution either. The trouble is that this separated loading doesn't influence the main AssetLoader's progress, so if I were to load hundreds of tiles for that map, displaying progress is getting complicated.
Sorry for offtopic but is Black still actively maintained?

@62316e
Copy link
Contributor

62316e commented Aug 3, 2020

Hi @digitalbreed,
In general I would consider packing all the tiles into texture atlas to avoid overhead.

Allowing to enqueue assets on the fly will cause complete events to be triggered multiple times.

As a workaround i would go for another asset manager only for tiles and each time it finishes loading just copy all the assets mAssets into main asset manager. I will try to find more elegant solution meanwhile.

Sorry for offtopic but is Black still actively maintained?

Not sure about "actively" but definitely "maintained".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants