2
\$\begingroup\$

I'm digging into Starling's CitrusEngine game engine. I try to understand the idea of structuring the game.

If you take a look at chrome.angrybirds.com or puddingmonsters.com you see that games load states (StarlingState's assets) dynamically which is smart. When the game starts a splash-screen displays, then you get a pre-loader which loads the main state (home, settings and choose-level view) and when you select a level a pre-loader displays again which loads the level state. This looks like they've constructed multiple parts for the game and then connect them together where the pre-loader is displayed when switching from one part to other.

How should we do that in Starling/CitrusEngine? What's the logic here? Flash games usually load all assets at the beginning which is not smart on mobile devices. Is it wise to have multiple StarlingCitrusEngine classes or you should handle the whole game in a single StarlingCitrusEngine class? Please explain in details.

Many thanks for answers.

\$\endgroup\$
1
\$\begingroup\$

You're comparing apples to oranges. The games you list are done in html5/javascript not flash. So it might be difficult to do the same in flash.

Additionally: Flash is dead on mobile. Steve Jobs basically banned it from the IPhone. It can be installed on later versions of android, but doesn't run very well (at least that's what I heard). Either use Html5/Javascript or develop directly for the mobile OS you're targeting.

\$\endgroup\$
  • \$\begingroup\$ Runs fine for the most part on my Galaxy S3... \$\endgroup\$ – Robert Rouhani Sep 2 '13 at 1:12
  • \$\begingroup\$ @Stephen Flash/AIR is not dead. You should check this gaming.adobe.com/getstarted. \$\endgroup\$ – xpepermint Sep 2 '13 at 6:13
1
\$\begingroup\$

You can do runtime asset-loading using Flash/AIR just as well as embedding the assets into your game. Personally, I like to embed the theme-related stuff into the app, because as soon as you do runtime loading, you'll want some sort of progress-bar, and that's where you'll need the theme.

All other assets, like further images, sounds, etc. can be loaded using the existing Flash APIs. In Starling, there's even a very handy class for that purpose, called AssetManager. It greatly facilitates loading of common game assets.

Here's an example:

var assetManager:AssetManager = new AssetManager();

// assuming there's an "asset" folder within your application directory
var myAssetFolder:File = File.applicationDirectory.resolvePath("assets");

// enqueue the asset folder, you can also add individual files
assetManager.enqueue(myAssetFolder);

// load all the enqueued assets (this will load all assets from the folder)
assetManager.loadQueue(function(progress:Number):void {
    // tracing the loading progress in the callback. Here you'll want to update
    // your loading-progress bar.
    trace("Loading progress is: " + progress);
});

There's also an article in the starling wiki with a slightly more detailed example.

Ideally, your scenes know about the assets they need and you can load/free these whenever necessary.

\$\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.