Thursday, February 14, 2013

Firefly Part 1: Setting up game project

In this tutorial we will move through whole process of creating game called "Zombie: Rising Up". This game is available on Google Play and Apple Store. To set up game project you will need Flash Builder 4.7 and Firefly SDK, also we will use AIR SDK 3.6. If you don't know how to install AIR SDK into your Flash Builder you can find instruction here. First of all you need to create Action Script Mobile Project and uncheck "Automatically reorient" checkbox and check "Full screen" one in the bottom part of the dialog screen. In the root of the project create two directories - "libs" and "resources". In the first we will put .SWC libraries and .ANE extensions, in the second we will put .fxg textures, icons and bitmap fonts. Unpack Firefly SDK and put all files from bin directory into "libs" folder. So now we need to set up project to use these folders: open Project -> Properties -> ActionScript Build Path and in the Source path tab add folder "resources" like showed below.



In the Library path tab add SWC folder "libs".

And finally in Native Extensions tab add folder "libs".

Open ZombieRisingUp-app.xml description file, set screen orientation into "landscape" (<aspectRatio>landscape</aspectRatio>) and renderMode into "direct" (<renderMode>direct</renderMode>), last needed for Starling to use GPU acceleration.

That's it, configuration is complete so know we will do some code. For this game we will use bitmap fonts, if you don't know how to generate them look at this starling post. Our main game class should be extended form GameApplication class that contains lots of logic to configure and start up Starling. In constructor specify design size and design DPI (you can read more information about this here).
public class ZombieRisingUp extends GameApplication
{
  public function ZombieRisingUp()
  {
    super();

    // Set textures size. For this particular game it will be:
    // Landscape: 1024 x 768 and 240 dpi
    setDesignSize(1024, 768);
    setDesignDPI(240);
  }
}
During initialization we will show two splash screens "company" and "game" just add them:
// Initialize company and game splash screens.
addSplash(new CompanySplash(), 2000);
addSplash(new GameSplash(), 1000);
These classes should be extended form Splash base class, you can find them in showcase project.

Showcase project source: ZombieRisingUp Part 1

4 comments:

  1. Amazing SDK , I will use it in my next game , I`m imported Firefly to Flash Builder 4.6 but GameApplication class has this Error : 1120: Access of undefined property debugging.

    Any Solution ? .. Sorry I don`t have 4.7 !!

    ReplyDelete
    Replies
    1. Hi, make sure that you have additional compiler argument (Properties -> ActionScript Library Compiler) -define=CONFIG::debugging,false

      Delete
  2. This comment has been removed by the author.

    ReplyDelete