Game Development Reference
In-Depth Information
Pan (or Drag) Gesture
A pan gesture is the kind of gesture you use in the Maps application to view different parts of the
map. A drag gesture is also used to unlock the phone or pull down the notification center. If you
think about it, these gestures are really the same thing: the user puts his or her finger down, moves it
in a mostly straight line, and then lifts it. The difference is in how the application responds. We call it
a pan gesture when the view pans over some content (e.g., a map or image). We call it a drag when
you move a UI component on the screen (e.g., the knob of a slider). Regardless of what we call it
in our description, this gesture is implemented with the class UIPanGestureRecognizer (sorry, drag).
Figure 8-4 shows an example using UIPanGestureRecognizer .
Figure 8-4. Pan or drag example
In Figure 8-4 we see three asteroids. Each asteroid can be dragged up or down along an invisible
path. When dragging an asteroid, you can move your finger all the way to the right or the left. This
makes it a lot easier to use because the user does not have to be too careful about where the finger
moves once the desired asteroid gets moving. This simple example starts with the header file for the
class PanGestureController , as shown in Listing 8-17.
 
Search WWH ::




Custom Search