O'Reilly logo

Learning Objective-C by Developing iPhone Games by Amy M. Booker, Joseph D. Walters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Moving our ship sprite

A sprite is a graphic/icon/image that is displayed inside a larger area of a screen. Think of it this way; if a fairy (or sprite) were flying around the screen with a background image of a princess castle, the sprite would still move independently of the background as an entity in itself.

For our current game, we have a ship sprite that we want to move from left to right. For our game example, we are going to add in a move-left and move-right button. Our sprite will move along its x axis when the buttons are pushed.

Let's start with creating the buttons. Create two button views in our storyboard, as shown in the following screenshot:

Open your assistant editor. Press the Ctrl key and click and drag your buttons to GameViewController.h ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required