Game Development Reference
In-Depth Information
The interesting part here is a second check for background speed in the
handleSwipeLeft: method. We don't want to go into negative or zero speed,
since our background generator works only with positive scrolling (from right
to left), and if we have negative scrolling, the background will end.
Another thing that we need to remember is to remove the gesture recognizer once
the scene gets removed from the view, as we might get another scene in the same
view that doesn't know how to handle these methods. Thus, your application will
crash at this point. To prevent this, add this method:
-(void)willMoveFromView:(SKView *)view
{
for (UIGestureRecognizer *recognizer in view.gestureRecognizers) {
[view removeGestureRecognizer:recognizer];
}
}
This gets called when our scene is about to be removed from the view. It iterates
over the gesture recognizers in the view, removing each of them.
Accelerometer
Accelerometers and gyroscopes in modern devices are probably the things that
have contributed to much of the popularity of iOS devices. Many people still play
Doodle Jump, a game where you control a character that jumps on platforms,
and is controlled by tilting your device.
Accelerometer controls have many advantages, which are as follows:
• You don't clutter the screen with game controls
• You don't need to cover the (already small) screen space with fingers while
playing your game
The accelerometer controls can imitate real-life interactions—such as a car
steering wheel
With new hardware (gyroscope) available on the latest devices (starting with
iPhone 4), you get precise data about the device's position, which leads to
smooth controls
 
Search WWH ::




Custom Search