Ship Attack

Ship Attack!

Ship Attack is a 2D side-scroller for iOS written in Objective-C using cocos2d. It’s an endless scroller where you control a space ship that has to shoot down flying saucers to survive. The objective of the game is to get as high of a score as possible before losing all of your lives.

Detail on the layout of the code is in Chapter 13 of the book. While this game is certainly simpler than the tower defense game in Chapter 14, the code may still be a little tough to follow without the explanation provided in the book.


All the sprites were created by Jacob Zinman-Jeanes: (Used under the CC BY license).

Binary Download

Because of the way code signing works for iOS devices, it is not possible to provide a standalone binary.

Source Download

The full source code is available on GitHub here. If you’re unfamiliar with the concept of source control, be sure to read the section on it in Appendix B of the book.

If you don’t have Git installed, and don’t want to mess with a client, you can also download the code in zip form.

Build Instructions

Due to the nature of development for iOS devices, a Mac is required (with at least Mountain Lion). You need to have Xcode 4.6.3 or higher installed on your Mac, as well (which can be downloaded for free from the App Store).

Simply open up shipattack.xcodeproj and you will be able to build and run on an iPhone simulator. However, due to the nature of two-hand touch controls, it’s recommended that you play on an actual iPhone. Unfortunately, this does require a development certificate from Apple.

How to Play

Slide a finger along the left side of the screen to move the ship up and down. Hold a finger on the right hand side of the screen to fire. This works best using your left and right thumbs.