Chapter    5

Reacting to Player Input

An important element of a game is that it reacts to what the player is doing. On iPhones or iPads, games mainly respond to touch input by the player, which also holds true for the games you develop while reading this book. Some games also use other input data such as the built-in accelerometer, which I’ll briefly discuss in this chapter. In order to deal with input data, you’re going to need a few new programming concepts, such as the if instruction, which will be introduced in this chapter.

Dealing With Touch Input

Any Apple device using a touch screen can track multiple fingers and how they move over the screen. The finger movements that a user makes can be interpreted as gestures (such as swiping to move ...

Get Swift Game Programming for Absolute Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.