O'Reilly logo

iOS 7 Game Development by Dmitry Volevodz

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

Using a controller in our game

As our game is not too complicated, we use only one button. We will map the same thing to a few buttons so that the players can use any one that they like.

The first thing that we need to do is import the GameController framework. In order to do this, add the following line to ERGMyScene.h at the beginning of the file:

@import GameController;

The preceding line of code adds game controller headers and links our project with the game controller library while it is compiling. After this, we will need two new properties in the same file:

@property (strong, nonatomic) ERGPlayer *player;
@property (strong, nonatomic) SKLabelNode *pauseLabel;

We will need a way to access our player object from the code that sets up the game ...

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