Game Development Reference
In-Depth Information
controller.extendedGamepad.buttonB.valueChangedHandler =
jumpButtonHandler;
}
controller.controllerPausedHandler = ^(GCController *controller) {
[self togglePause];
};
}
At the beginning of this method, we create a handler for the directional pad and
thumbsticks—if the player presses the up button on the pad or moves the thumbstick
up, we will have the Y value going up from zero. Thus, we start jumping by setting
the accelerating property to YES .
After that, we check if the controller has an extendedGamepad profile, and if it does,
we attach this handler to the thumbstick. If it is a regular gamepad, we attach the
handler to the directional pad.
The same procedure is repeated when we declare a handler for a button—it checks
if the button is pressed and our character jumps; if it is, we set the A and B button
handlers to this handler.
The last handler that can be found in this method is the pause handler. It will get called
when a player presses the pause button. The following is the code for this method:
- (void) togglePause
{
if (self.paused) {
self.pauseLabel.hidden = YES;
self.paused = NO;
} else {
self.pauseLabel.hidden = NO;
self.paused = YES;
}
}
Here we check if the scene is paused, and if it wasn't paused, we pause it and show
the Pause label. If it was paused, we continue the scene and hide the label.
 
Search WWH ::




Custom Search