1
\$\begingroup\$

In my game more than 600 images and 200 sounds. I'm try organize effective images and sounds manager for fast access. This is a good approach?

public class Images 
{
    public static var image_1:BitmapData;
    public static const image_1_class:Class;

    public static var items_icons:Vector<BitmapData>;
    public static const item_1_class:Class;
    public static const item_2_class:Class;

    ...
}

// initialization
Images.image_1 = new Images.image_1_class().bitmapData;
Images.items_icons[0] = new Images.item_1_class().bitmapData;
Images.items_icons[1] = new Images.item_2_class().bitmapData;

// using
new Button().setTexture(Images.button_close);
sounds.playRandom(Sounds.gnome_hit);
\$\endgroup\$
0
\$\begingroup\$

Obviously it isn't a good approach to inline ~800 assets because it really is a chore to set up. You could pack your images into an atlas, so that you only have to load one or a few large files.

It also depends whether or not you want your resulting swf file to include all the assets or if you can load them from external sources. If the latter is the case, you could load all files from a folder (when it's an AIR application) or load the files from a webserver.

You could also write a shell-script that writes your "Asset-Classes" automatically. Eg. some script that lists all files from your asset folders and creates the actionscript for them automatically. That way you can do something more productive than referencing 800 assets manually.

If you're looking for ideas how to write an asset/resource manager, I suggest you have a look at the implementation of the AssetManager inside the Starling Framework.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.