Designing an Open-Source iPhone Game

The iPhone, one of the most loved and admired smartphones out there has recently been converted into a genuine gaming platform. Everybody downloads games and apps on his device, but what about designing an open-source iPhone game? What does it take to do that?

For starters, it’s really important to have some iOS skills and know some things about coding. For the average individual it seems the whole process seems what to complex but when you have the tools you just have to put the pieces together and have some imagination.

iOS development with Objective C

To begin with, you’ll need a Mac and an Apple Xcode development environment available for free. After you’ve prepared the Xcode, you can move ahead and download the GitHub project. Open the project and hit ‘Run’.

For a better understanding of how to design an open-source iPhone game we will use an already made game as an example. It’s called ‘Seven Bridges’ and it’s a puzzle game. The interaction of the game works using a single tap gesture. The player can move wherever he wants as long as you manage to cross the bridge.

‘Seven Bridges’ is one of the simplest games for the iOS. It does not have the complexity of Angry Birds or the accuracy of Infinity Blade. Still, it’s engaging if you like puzzle games. ‘Seven Bridges’ was written using a mix of Objective C++ and Objective C, so if you’re already accustomed with programming languages such as JavaScript, Objective-C will come as a surprise.

iOS programming

When you use JavaScript all you need to do is hit the jQuery button and move on from there. A lot of tutorials that showcase programming for iOS make things seem so easy when they’re really not. Objective-C has roughly 30 years and in order to learn it you need fundamental concepts regarding its overall structure. When you begin using Objective-C, it is assumed that you already have a strong background of the C programming language.

Unlike JavaScript, Objective-C is extremely different because you need to have an understanding of old-school programming techniques.

The files

Now that the code is already on your computer, it’s time to understand each file by looking at its corresponding extension.

  • .h – class headers
  • .m – Objective-C implementation files
  • .mm – Objective-C++ implementation files. C++ is regarded as a hybrid where you can make use of both C and C++ in an equivalent file
  • .xib – defines visual views within the fame permitting you to lay controls and buttons
  • .png – individual images for the game
  • .pvr.gz – massive sets of images known as ‘sprite sheets’
  • .plist – XML properties files that define how the app works
  • .m4a – audio files of the game


The game we used as an example makes use of 3 main frameworks:

UIKIT – each and every iOS app begins with UIKIT, an Apple framework that offers basic controls of your application like button, text fields, and windows. The UIKIT prefix is ‘UI’ and it can be seen ‘UIWindow’, ‘UIButton’. The framework can be easily used through a visual editor offered with Xcode. Hence, Xcode will facilitate the drag & drop controls for your app.

The other two frameworks you can use are COCOS2D (allows you to dram directly with OpenGL) and BOX2D (a physics engine that is written in a portable C++ and it can manage variable such as friction and gravity).

Creating the Scene

Level Layer will be used to draw the playing area of the game, which is created from an image set known as ‘sprites’. Every item from the scene of the game, like the river or the bridge will be created from a separate image file.

When using images this way rather than creating them programmatically, they will run much faster. Using a sprite sheet will provide performance and that’s the main reason we will use it.

Pixels, tiles and points

The iOS manages 5 devices: iPhone 3.5 inch, 3.5 inch Retina display, 4 inch Retina display, iPad, iPad Retina Display

In order to support each and every device means that the iOS must also handle various layouts. The COCOS2D framework can help you a lot through its supporting points rather than pixels when stating layout. Pixels are exact screen location while points are much more relative for the device.

Collisions and boxes

Every object present on the screen is known as a ‘sprite’. COCOS2D can easily manage the animation and position of the images, however it cannot know if they collide. In this case, using BOX2D is a much smarter option.

How to define levels

Each and every game level is defined by a separate JSON doc. It’s important to separate the level definitions from the actual code in order to update levels and add new levels without having to change the code.

Each and every object comes with a coordinate within the tile system, as well as a set of properties meant to define the object’s moving mechanism. A lot of games define certain levels in XML; however, a game developer can also opt for JSON because it can parse faster and it works smoother on the web.

Jason Phillips wrote this awesome post. He is a regular guest contributor at various sites. Also he is a co editor at Sniper Games 365.

VN:F [1.9.22_1171]
Rating: 10.0/10 (3 votes cast)
Designing an Open-Source iPhone Game, 10.0 out of 10 based on 3 ratings

No comments.

Leave a Reply