In this tutorial we’ll create a basic User Interface for a game using several methods (flash pro, Starling, Feathers) and learn how to use the LevelManager class.
We’re creating a game using Starling framework. It means that it runs on Stage3D technology. So the first thing you have to take care of is : don’t mix flash display list elements with Stage3D content, or there will be bad performances. The game HUD must use Starling elements or Feathers.
For the menu, there is an other deal : you may create it inside Flash Pro and use it quickly. If there isn’t any fancy effect, performances will be fine.
StarlingState class extends starling Sprite class, so it means you can easily addChild HUD elements which will be on top of your game. Don’t use StarlingState class as a menu or anything which is not the game.
By default, the game state will be displayed at index 0. It can be easily changed thanks to the _stateDisplayIndex protected property from CitrusEngine class. Don’t forget that the state is added once a new one is created.
Finally, if you use Starling for your menu, be sure that the Context3D has been created before adding any object to Starling. You just need to override the protected _context3DCreated method from StarlingCitrusEngine.
In many games, you can choose a level. Most of the code can be similar between each level : the way they are created, camera target, the logic itself… The Citrus Engine, thanks to the LevelManager class, helps you to create quickly new levels. The LevelManager is based on an abstract class : in this class you will create everything which is common to each level. Keep in mind that everything should be overridable. Then you create one class by level which extends your abstract class and you’ll be able to redefine what you need and add new stuff.
There is a snippet which explains how to set up the LevelManager. It is a bit complex to handle at first since there are many things to set up, but very powerful later. Use it, or create your own.