Allow adding additional assets to the queue after loadQueue is triggered
digitalbreed opened this issue · 3 comments
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.
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.
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?
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".