Skip to main content

cross platform solutions

Cross platform mobile development frameworks.

I have tried unsuccessfully many times to pick up Objective C and develop for iOS. A forum discussion with Adobe Flash developers at the Build Brighton Hackspace (2013) opened my mind to the potentials of cross platform development, when they indicated that Adobe Flash contained a facility to compile to iOS, or indeed any number of target platforms.
This chapter reviews the range of cross platform mobile development frameworks.

Cross platform development solutions.

My project originally set out to compare the performance of games created using native and cross platform frameworks, with the aim of quantifying the notion that native development would provide more efficient and faster playing games. An initial review of the processes employed by commercial games developers indicated this was a false assumption.
Research papers like Rabeiro and Silva’s (2012) Survey on Cross-Platforms and Languages for Mobile Apps and Dickson(2012) - Cabana: A Cross-platform Mobile Development System - seem to consider a wide range of cross platform frameworks on an equal footing which contrasts with the narrower views expressed in my discussions with developers in London and Brighton, indicating different drivers in academia and business.
The Game Developer Magazine 2012 survey highlighted that developers tended to use multiple toolsets, but the majority (53.1%) used the game engine Unity

39.8% used a custom engine,
17.7% used one form of the Cocos2D framework,
5.3% used Marmalade, and 5.3% used Corona.

The survey ranked the most important features in order: "Rapid development time" most important,
then "Flexibility and easy extendability",
"Engine performance",
"Support and documentation", and "Prior successful use by another team"

Available solutions.

The Unity game engine

The Unity game engine is an extensive GUI driven toolset that is aimed at building complex 3D games environments. It supports scripting in JavaScript, C# or Boo, and runs on the Open Source .NET platform, Mono.
Unity is used by many successful development houses, and picked up 17 awards in the Apple App Store Best of 2012 awards. It was listed as the No.1 game engine by Game Developer magazine (May2012)
Fireproof, The Room: Rovio, Bad Piggies:
Unity can build from a common code base to deploy to a very wide range of platforms, which is part of the reason for its success. Standard builds are available for Web Player, PC, Mac & Linux standalone, iOS, Android, Google Native Client, X-Box 360, PS3, Wii and Flash Player. Unity forms part of a toolchain that is well suited to a larger development environment, where 3D modellers and texture artists feed their outputs into the process.

The Cocos2D framework.

The Cocos2D framework is available under a permissive MIT licence, it is flexible and adaptable, but requires platform specific coding, and the use of Xcode and the Java Development Kit (JDK) respectively to build for specific platforms. There are three main flavours of Cocos2D:
The Cocos2D-X is a cross platform OpenGL framework - which uses C++. Cocos2D-iphone uses Objective C and integrates with Xcode through a set of templates.
Cocos2D-HTML5 framework (A variant of Cocos2D-X)- uses Javascript.
Touch Press, The Elements: id364147847
Zynga games, Farmville:
In the early stages of the project I was pretty sure that Cocos2D would be the framework I would use. Building the basic physics demo in Cocos2D is quick and easy, but creates a vast number of templated file (252 files), which need to be compiled, this slows down the build/test process. The updates in iOS and Cocos2D don’t seem to be synchronised, and many of the calls in Cocos2D are to deprecated APIs, leading to a large number of errors and issues. The Xcode IDE is complex, but provides comprehensive control, code completion, on the fly error checking and useful debugging tools. The Xcode simulator supports a full range of iOS devices. The tools for Android specific development are less developed, though Traditional Java tools like Eclipse and Netbeans seem popular. Google (who created Android) do provide an IDE based on IntelliJ, and indeed a transcoder from Java to Objective C, however the bundled simulator is poor.

Example Cocos2D code:;
    import android.os.Bundle;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
       /** Called when the activity is created. */
       public void onCreate(Bundle savedInstanceState) {
          TextView text = new TextView(this);
          text.setText("Hello World!");
} }

Marmalade quick sdk.

Marmalade Quick is an open RAD programming environment, built from OSS components including Cocos2d-x and Box2D. Coding in Marmalade is done in C++ or C, and Quick provides an abstraction layer that uses Lua to speed up cross platform building. The tool uses precompiled native code to build to the widest range of platforms including Windows phone, Nook, Blackberry 10, iOS and Android, even Roku boxes without knowledge of the low level system APIs. Because of the very wide range of Android devices Marmalade has a number of custom Android deployment options. Marmalade Quick is a free tool, with installers for Windows, Mac, but requires the Marmalade SDK which starts at $149pa for a version that deploys to OS and Android, and rises to $3499 per seat per year for the Professional version.
Marmalade, Signal to the Stars:
EA, Plants vs Zombies:
Using "raw" Marmalade isn't a pleasant experience, there is no specific IDE, no hand-holding, but this may be a benefit for a team with competent C++ coders. As might be expected building a basic hello world C++ Marmalade app is long winded:
Example Marmalade code:

//Include access to OpenGL abstraction layer -
#include "s3e.h"
//include access to Open GL abstraction layer -IwGx is built on top of s3e - could use
//Iw2d for 2D application
#include "IwGx.h"
int main()
    // Initialise software renderer
    // Set the background colour
    IwGxSetColClear(0, 0, 0xff, 0xff);
    // Loop until app quits
          && !(s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN)
          && !(s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN)
        // Clear the renderer
        // print string using default font at 120, 150
        IwGxPrintString(120, 150, "Hello, World!");
        // sleep for zero ms
    // close renderer
// Return
return 0; }

The Marmalade Quick abstraction layer provides much faster access to the basic Open GL tools through Lua scripting, to achieve the same effect as above.
Example Marmalade Quick code:

//create Label called label put it at 0,0 and display “Hello World” in default font
local label = director:createLabel(0, 0, 'Hello, World!')

The Marmalade team has created a desktop simulator that can be configured to a range of devices, and built integration in to the OSS ZeroBrane Studio IDE.
T. Closs (2011) of Marmalade UK indicates that whilst authoring in Lua means working further from the metal, and inevitably takes more CPU cycles than authoring in C++, for most 2D games, which are GPU bound, this isn't noticeable.

Corona SDK.

Corona offers multiple versions from free through to full enterprise, at $2500 pa, with progressively greater feature sets.
The Free Starter version, and indeed the Pro version don't offer native code support, however the API is extensive. Corona provides a very quick development process using the Lua scripting language. Lua is used widely in "World of Warcraft", and Steam games- such as the popular "Garrys mod" in the Half Life 2 engine, and "Angry Birds", but also in high performance web applications, mobile applications like Spotify, embedded systems, desktop applications like Adobe Lightroom, or embedded into systems like Redis or Nginx and in financial services.
Corona claim a 250,000 strong developer community with 27,000 live apps, and 1.6 billion app sessions a month (recorded with their built in tracking tools)
Advice from Build Brighton developers suggests that Lua, and indeed Corona are a useful toolset to learn, and work very well within their limits.
Seb Lee-Delisle presented a session on Corona at the UPDATE11 conference:
"I love Corona – like any simple accessible platform, it has limitations, but if it can do what you need, you can produce excellent results very very quickly indeed. It’s very good at moving bitmaps around (with GPU acceleration) and has Box2D (physics engine) built in, so it’s perfect for an Angry Birds type game."

EA, WordSmack :
PagodaWest Games, Major Magnet:
Example Corona code:
--create local display Object called myTextObject, assign it value “Hello World” and add
to display at 0,0
local myTextObject = display.newText( "Hello World!", 0, 0)

Framework selection.

After testing trial versions of each of these platforms, and many others, I rejected the use of Unity for the project, due to a very high recurring licence cost, and as the engine is chiefly focussed on 3D development. 
Unity provides a menu and form driven interface which is exceptionally complex and better suited to a larger development teams, as part of a production pipeline. I didn't feel I had time to learn Unity properly within the project timeframe. However it certainly seems to be the most popular tool with commercial developers.

Cocos2-D provides Xcode templates, and has no licence costs, unfortunately specific builds are required for the various platforms, which means the aim of a single code base isn't possible making it out of scope for this particular project. However the flexibility and capability to use native code whilst handing over Open GL complexity would be very compelling if I was working in a software environment that dictated native code components. This is more likely in business apps where display widgets and a familiar system look and feel have to be followed.

I visited the Marmalade offices in London and was impressed by their development processes and product. The 'Quick" tools are a spin-off of tools they use to develop their own applications. Unfortunately the Marmalade licence is expensive, and the trial version only lasts 30 days, so it too was discounted. The Quick tools are well provisioned, and the fine tuning for platforms is extensive, and offers the very widest cross platform deployment opportunities.

I settled on Corona SDK as a good representative of the development frameworks, and because it is well matched to the rapid development approach I intended to use.
Corona provides 500 APIs that hide a lot of complexity making many routine tasks very easy to achieve. Lua, is a very simple, fast and widely used scripting language, making it a useful transferable skill. The Free starter version provides sufficient functionality to meet the needs of the project. 

Popular posts from this blog


Spine again - animating game assets

Laura Tallarday gave a neat demo of how to build an animation in Spine on the CoronaGeek Hangout, so I had a bash at chopping up an image and animating it.
The plan is to add some more sophisticated animations to the new game "Duck sized horse".. but as was discussed in the show adding a whole bunch of spine animated objects might hammer a mobile device... and as the aim is to have 100 tiny duck sized horses, I'd best choose another approach for them.

anyway here's a swaying viking...

Using Corona SDK

Corona Architecture Overview
Diagram showing the Corona SDK architecture -source Walter Lua - CEO Corona The development process. I built the game "Ninja Dinosaurs vs Pirate Robots" in a series of 4 development sprints. I used a familiar game format, the "Infinite Runner" to guide the overall structure, and built the game using the Agile development methodology and Simplicity principle: "simplicity: write the simplest code to do the job, do not provide hooks in your code for ‘future needs" - this prevents scope creep. Studies by Jones (2009) have shown that Agile is most effective with small teams. Agile focuses on swift iterative cycles creating instances of working code, which are constantly reviewed and guided by the end users rather than a rigid commitment to a fixed system architecture. It values working code over heavy documentation, as might be encountered in a more traditional waterfall development approach.
Game Summary. Whilst the game is an inf…