Starling Builder Best Practice

Load in atlases, not individual pngs

Here's the reasons:

  1. AIR will throw an error if the textures numbers exceed its limitation
  2. Assets are grouped by atlases, you won't get the grouped feature using individual pngs

Let the editor and the game use the same assets

Always DRY(don’t repeat yourself), even for assets. They may need to be in different directories, but you can easily link a directory to another using symbolic link.(more information)

Everything should go with design resolution, even textures

Determine your design resolution before you make the game, and scale everything based on it. This also applies to textures. If you scale your textures to the right size then you don’t need to scale the display objects individually. (more information)

Customize the editor

The editor is highly flexible to change. Everything in the properties panel is customizable by changing settings/editor_template.json. Anyways make sure to backup your custom template file before an upgrade. Since it will override your custom template if the default template is changed.

Cache the layouts in game

Parsing strings is considerably slow, you should avoid parsing the same JSON layout multiple times by caching the parsed layouts in the memory. UIBuilder.create() can accept both parsed (as3 object) and unparsed (JSON string) data. It’s highly recommended pass in parsed data to increate performance, espicially when you are creating many instances of them (e.g. ListItemRenderer)

Create dynamic contents in game

There are many ways to create dynamic contents, feel free the choose the way work best for you

  1. Create a holder container, add in place holder component in editor(forEditor = true), add in the actual one in game
  2. Use customComponentCls to create game dependent class object in game
  3. Manually replace component with another component in game
  4. Write your own UI component and compile to EmbeddedComponents.swf. Load in the swf file and use it directly in the editor

Use UIBuilder.create with binder

Passing in a binder object with UIBuilder.create can make your life easier and display object naming more consistent. This way you can remove all the boilerplate code like _exitButton = _sprite.getChildByName(“_exitButton”) as Button;

  builder/best_practice.txt · Last modified: 2016/03/11 21:08 by johannh
Powered by DokuWiki