Game Development Reference
In-Depth Information
Chapter 8
Building Your Game:
Understanding Gestures
and Movements
The really neat thing about creating games for mobile devices is the unique way that the user
interacts with the game. The complex gestures supported by iOS are a relatively new way to interact
with a computer, and new interface techniques can give users trouble if they are unfamiliar with
them. However, users of iOS are already familiar with the concepts of double taps, pinches, and
swipes, so including these gestures in your game does not present a usability problem.
In this chapter, we will explore how you can add gestures to your application or game using the
built-in libraries provided by iOS . We will also explore how to attach specific gestures to specific
actors in a game. By the end of this chapter, you will know how to work with all supported gestures
and be able to use them to drive user interaction in a game. We will be using the familiar classes of
GameController , Actor, and the rest, in our examples. So your understanding of these gesture events
will be tied directly into what you have learned in the previous chapters.
Beyond simply touching the screen, users can interact with iOS 6 applications through the
accelerometer or the gyroscope included in the newer devices. Using the motion of the device as
input to a game opens up a new dimension to the user experience. We will explore how to use the
sensors and tie them into game events.
Touch Input: The Basics
There are really three ways to accept touch input from the user. The first is to use buttons or other
prebuilt widgets and implement tasks that respond to the user events. I am not going to go through
the details of this type of input, as it is the most basic, and is well covered in all iOS introductory
topics. The second method is to create subclasses of UIView and implement a number of
185
 
Search WWH ::




Custom Search