Game Development Reference
In-Depth Information
4. Then, at the end of the update method, we start adding the lines that will dis-
play the rest of our tutorial information. First, if the player sprite is in the midst of
a jump and has just begun falling, we use the following:
if (_state > kGameTutorial) {
if (_state == kGameTutorialJump) {
if (_player->getState() == kPlayerFalling &&
_player ->getVector().y < 0) {
_player->stopAllActions();
_jam->setVisible(false);
_jam->stopAllActions();
_running = false;
_tutorialLabel->setString ("While in the air,
tap the screen to float.");
_state = kGameTutorialFloat;
}
As you can see, we let the player know that another tap will open the umbrella
and cause the sprite to float.
5. Next, as the sprite is floating, when it reaches a certain distance from the build-
ings, we inform the player that another tap will close the umbrella and cause the
sprite to drop. Here's the code for these instructions:
} else if (_state == kGameTutorialFloat) {
if (_player->getPositionY() < _screenSize.height
* 0.95f) {
_player->stopAllActions();
_running = false;
_tutorialLabel->setString ("While floating, tap
the screen again to drop.");
_state = kGameTutorialDrop;
}
6. After that, the tutorial will be complete and we show the message that the player
may start the game:
} else {
_tutorialLabel->setString ("That's it. Tap the
screen to play.");
_state = kGameTutorial;
Search WWH ::




Custom Search