Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.87k stars 824 forks source link

Zip support in AssetManager #697

Open MarkReedZ opened 9 years ago

MarkReedZ commented 9 years ago

AssetManager should probably support zip files. Given a zip it can give access to the images/sounds/etc via the zip internal file names.

This is discussed on the forum here: http://forum.starling-framework.org/topic/assetmanager-addition

The only gotcha is that for textures it needs an onRestore that loads from the zip file.

PrimaryFeather commented 9 years ago

Yes, I agree that this would be useful! Mhm, "onRestore" will be a little tricky.

In any case, anyone who'd like to see this feature please comment here, so that I can prioritize! Thanks in advance.

vpmedia commented 9 years ago

I think AssetManager should be an Extension with more robust functionality..

In my case (inhouse 2d game engine), I'm using my own AssetLoader library which needed to have advanced file format support:

I think https://github.com/Matan/AssetLoader & https://github.com/hydrotik/QueueLoader/ & https://greensock.com/LoaderMax-AS3 & https://github.com/arthur-debert/BulkLoader are good examples for this kind of Loader architecture.

Also generally my Starling/Application classes are not in relationship with the AssetLoader but with a CacheManager class which registers various Flash assets (BitmapData, DisplayObject, ByteArray) recieved from AssetLoader.

So for example ZIP files are destroyed after Loading + Parsing and only the Parsed file contents (BitmapData, ByteArray, String) are stored in memory for later re-usage.

This way Texture onRestore works without any extra trouble.

b005t3r commented 9 years ago

I don't think it really matters wherever AssetManager is going to be a separate extension or stays with Starling, but what I'd really want to see is a way of adding custom loaders/parsers as plugins for file types like ZIP, SWF, etc:

assetManager.registerPlugin(new ZIPLoader());
assetManager.registerPlugin(new SWFLoader());
PrimaryFeather commented 9 years ago

Agreed, the Asset Manager should have better (and well documented) options for extending it. On my TODO-list!

I consider it an integral part of Starling, though, especially since it's the only way I can offer developers a simple way of handling a context loss automatically. That can only be done in a resource manager like that.

Fraggle commented 9 years ago

I also hacked the Asset manager for more file format support. Getting it for free would be lovely.

Maligan commented 9 years ago

Subscribe, and doube agree with b005t3r

Jacowaco commented 9 years ago

I think SWC and SWF support is very necessary. Specially to be able to load background music that needs to loop gaplessly in an SWC without having the big weight of the music adding weight to your file.

kheftel-old commented 9 years ago

agree on SWC support - it'd be nice to get Sound-object-compatible seamless looping MP3s (which need to be encoded by flash to work gapless-ly :P ) without having to embed them in the executable.