Chapter 3. Interacting with Our Game

In this chapter, we will discuss the ways in which we can get input from the player. As there are many different ways to handle user input, we will see the advantages and disadvantages of each of them. Some of the ways to interact with the game are as follows:

  • Touching the screen (taps)
  • Gesture recognizers
  • Accelerometer and gyroscope
  • Game controller events

Handling touches

When the user touches the iOS device screen, our current running scene will receive a call to one of the following methods:

  • -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  • -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  • -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
  • -(void) touchesCancelled:(NSSet *)touches ...

Get iOS 7 Game Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.