Starling-Framework icon indicating copy to clipboard operation
Starling-Framework copied to clipboard

Zip support in AssetManager

Open MarkReedZ opened this issue 9 years ago • 8 comments

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.

MarkReedZ avatar Mar 31 '15 02:03 MarkReedZ

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.

PrimaryFeather avatar Mar 31 '15 08:03 PrimaryFeather

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:

  • Loading Font SWF as ByteArray (https://github.com/vpmedia/runtime-font-loader-as3)
  • Loading and Parsing .properties (Key=Value) files for i18n
  • Loading Zip, SecureZIP, custom WAD like packages..
  • Loading SWC and SWF class libraries
  • Registering new type of Files with Parsers.. (Text, XML, CSS, MP3, etc.. support)
  • Parallel and Local AIR file (pre) loading..
  • Loader should be usable without Starling

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.

vpmedia avatar Mar 31 '15 10:03 vpmedia

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());

b005t3r avatar Mar 31 '15 11:03 b005t3r

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.

PrimaryFeather avatar Apr 01 '15 12:04 PrimaryFeather

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

Fraggle avatar Apr 03 '15 10:04 Fraggle

Subscribe, and doube agree with b005t3r

Maligan avatar Apr 14 '15 08:04 Maligan

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.

Jacowaco avatar Oct 19 '15 23:10 Jacowaco

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.

kheftel-old avatar Oct 20 '15 00:10 kheftel-old