Get Updates By E-mail 

Article Written By:
Johann Dowa

Beginners iPhone Action Game Tutorial: Source Code


A few weeks ago I posted a short video similar to this one:

UPDATE: Tutorial Has been posted!

I’ve been asked since then when I would come out with the tutorial.   I was finally able to get around to completing the source file, and I’ve added line by line (well pretty close) comments in plain english to make it easier to follow.

The above video utilizes the exact source code from this tutorial running in the iPhone simulator.

Following the suggestions of a friend of mine who is just starting to learn this I’ve used as few methods as possible, and made extensive use of autorelease objects to make the flow easier to follow for beginners.

The tutorial features:

  • Loading/Placing Images
  • Animation
  • Touch Events
  • Text
  • Sound Effects
  • Background Music
  • Buttons
  • Resetting The Game

Coming up next week I will be posting a more comprehensive tutorial, but I am posting the source code now.  If you look through this code and the comments you should be able to grasp what is going on, and I hope that the upcoming tutorial will fill in the gaps. Be sure to come back next week when the full tutorial is posted!

I recreated this from scratch using Sparrow Framework and Objective-C because in my findings it was easiest to follow for a beginner looking to create an action game.

Things could change a little as I haven’t really looked through it myself.. just quickly coded it and wrote line by line comments. If you open it up, and are wondering which files to look at to understand things go to the Game.h and Game.m files.. the app delegate files were created automatically with the Sparrow project and I didn’t comment those.

Update! I have modified the project to remove an error that occurred on some systems due to a recursive search being done in the project for already included files.  Please re-download if you encountered this problem.

You can download the source with music/sound effects here:

Graphics are included so the example will run but are slightly different because I am using graphics similar to those in the video in my own game.

As far as licensing goes feel free to use this in your own apps, and if you do send me a message or post a comment about it, and I’ll mention it on this site. You may not use any portion of this project in your own tutorials, books, etc. (and definitely don’t submit it to a site buying tutorials.. you know who you are!) without permission.

Please be sure to check back next week when the entire tutorial is posted which will give you a much better idea of how to extend/use this source code and utilize the Sparrow Framework.

If you have any questions as to why I did something or have any suggestions for the tutorial then please post them below — it will help to make the final tutorial better.

Also, if you could share this post that would be great too and help motivate me to make more!


Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.