[In this reprinted #altdevblogaday in-depth piece, independent game programmer Amos Laber examines several considerations when planning a game with Flash as the primary platform and iOS as the secondary.]
This is a continuation of my previous post Jumping from Web to Mobile, Part 1 about planning a multi-platform game.
Here I will present a blueprint for an actual port of a specific game project. This is a typical 2D game that feature scrolling backgrounds, animated characters, and touch (or mouse) controls. This should give an overview to the practical aspects of planning and building a game on Flash as the primary platform and iOS as the secondary, with possible porting to Android later on.
Choosing Flash as the primary platform enables experienced Flash developers to take advantage of the quick designer-to-developer tooling available, namely Adobe Flash Builder and Flash CS, to easily setup gameplay code over a framework, and create a quick prototype of the game before spending more resources on porting to mobile.
Although this is a subjective choice I made, it makes more sense to start developing on a desktop environment, as iOS developers often do, to achieve shorter development cycles.
There are few different options for going mobile from Flash, the first is Adobe AIR mobile. Adapting a game to AIR requires very little code changes and it deploys to a wide range of mobile platforms. AIR has its advantages, and while it may be the right choice for some projects, it is not in the scope of this article- the focus here is on using native code for mobile.
Frameworks and platform differences
In recent years, a new breed of modern game frameworks has emerged and is gaining popularity among game developers. Most of them free and open source, they borrowed practices from web, desktop, and mobile platforms and include an impressive array or out of the box features.
Such frameworks are Cocos2d and Sparrow for iOS, and Starling and ND2D for Flash. Starling is actually a port of Sparrow, using almost identical class names, while ND2D is closer to Cocos2d in style.
Regarding content, all of them use the same asset types for images and animation, which make the game content portable when switching between one framework to another. This includes sprite sheets, animation data files and particle effect data (in json and xml).
As a side note, both Starling and ND2D use the hardware accelerated GPU rendering (Stage3D) available in Flash 11. In some cases, developers opt for the software renderer to target wider range of users – and use their own custom framework that supports blitting, or alternative game frameworks like Flixel, FlashPunk and PushButton.
Whatever choice is made, being comfortable with the language and framework you use translates directly to efficiency and shorter timelines. The same goes for art tooling.
The above list of target platforms is by no means the only choice for the the platform, but it's a choice based on my own preference to code in a strict typed, object-oriented environment (sorry, Javascript and LUA).
Armed with a game framework for the platform and a set of tools we are ready to move on to technical design.
Architecture and code structure
As it turns out, clean and structured code is much easier to port than messy, over complicated one. Rule #1 is keep it clean.
The key for easy porting between platforms is building the right architecture. All the proper OOD methodologies apply, and most of all encapsulation and minimizing dependencies. First we need to create a separation between framework (engine) and game logic.These form the two tier architecture where dependencies goes from higher level to lower level modules.
Within each tier, we make a subdivision between platform independent code and platform specific code. This may not be clear cut. The goal is to isolate the platform specific code and keep it to minimum. In some cases we need to create an abstraction layer over that module, but usually this abstraction is already in place in the framework.
The content tools
As already mentioned, the said frameworks all use the same type of assets, so the same tools can be used across platforms and frameworks. All graphical assets are bitmap based and the most common use is for textures, sprite sheets and animation data.
Here are a few good tools for packing sprite sheets and designing particle effects:
More mobile: Android
The same process applies for Android, using libGDX as the game framework. It may be easier to use the ActionScript project as the source and use the iOS project as a reference, since Java is closer in nature to ActionScript that to Objective-C.
There are plenty of Android specific issues to address, but I will not discuss them here. The main idea is that most of the game code and content (assets) will work almost without change and the project can leverage the work that was already done in the iOS port without having to rewrite any of the components.
Conclusion
Planning a game to be deployed on multiple platform is now within reach for small, indie studios. With borrowed practices from the desktop and console space, modern frameworks such as Cocos2D allow a team of developers to leverage knowledge and expertise gained in one platform to be applied on other platforms.
[This piece was reprinted from #AltDevBlogADay, a shared blog initiative started by @mike_acton devoted to giving game developers of all disciplines a place to motivate each other to write regularly about their personal game development passions.]



- TexturePacker
- Zwoptex
- Particle Designer (Mac)
- Particle Editor (Windows)
- process user input and game state
- update all game objects
- draw/render the display list
- Switching the Framework
- Porting the Game code
- Porting the contents (game assets)
- Converting to touch controls
- Adjusting to screen size, language constrains and specific platform optimization

Coordinate systems are different between Flash and Cocos2D. Flash uses the top left corner as origin with Y-down, while cocos2d uses the OpenGL coordinate system, where the origin is at the center and Y-up. If you used Nd2D, there is no need for conversion of coordinates.