Today I released my first game for iOS. It is called Solar Balls, and is a simple arcade game where you have to flick coloured balls into the correctly coloured target. The game has:
* 16 mission levels
* 3 bonus levels which become unlocked when your score is high enough
* An arcade mode where you just have to get the highest score possible
The aim of the game is to save the Earth from the Solar Balls. They are heading towards our planet, and the only way to prevent them from destroying our planet is to fire them into the matching targets.
Game background and technical information
I wrote this game for fun, and to learn some iOS programming. It is built on top of the Cocos2D game framework. I tried first coding it using UIKit, but it was far too slow once I had more than 5 balls on screen at once.
Cocos2D is built on top of OpenGL and was easily fast enough to run at 60FPS on my 2G iPod Touch even with 20+ balls on screen.
I did mix in a bit of UIKit for the menu buttons, and also to construct the sprites. Cocos2D has no easy way of drawing simple anti-aliased shapes such is circles, or dotted lines. I therefore drew these offscreen with UIKit and then imported the image data into a Cocos2D sprite.
The physics is coded using Box2D. Originally I wrote the ball bouncing and collision code myself, but once I started adding angles and obstacles into the level it became obvious that I really should just use a physics engine to save me a lot of pain. As Box2D is written in C++ this has the knock on consequence that any parts of the game that interface with it also have to be written in C++ instead of Objective C.
I used the Particle Designer tool to make some of the explosion particle effects.
The game sounds use the OpenAL framework for low latency, and the background sounds use the simple AVAudioPlayer. I used the Finch wrapper to simplify using OpenAL, but had to customise it to handle automatically pausing/restarting the audio when necessary (e.g. if an incoming call occurs, or the game is backgrounded).
I found that the audio was the biggest user of memory. I had to re-convert many of the samples to lower bitrates to reduce the app size. Also I found that it was best to completely unload all audio and the audio framework if the game was backgrounded. I then reloaded all the audio again if the game was brought back to the front.
I’m not an audio or sound person so I made use of free images and sound effects. For the background I was able to make use of NASA great collection of copyright free images. As an extra touch I added information about each of the images to the start screen of each level (click on the level location at the bottom to see it).
It can be time consuming to produce multiple sets of images (original iOS screen resolution / retina display / menu buttons), so I wrote a script using ImageMagick to automatically convert each source image into the correct resolutions and to give them the correct names.
The sounds all come from freesound.org. This is a great resource for free game audio, but make sure you understand the licence terms for each sample. They have several different licences in use on the site.
XCode was really easy to use, as was debugging on hardware. In fact debugging on hardware is just as easy as debugging on the simulator which certainly encourages you to continually test on the real hardware.
Solar Balls is available now on the App Store.