Game Development Reference
In-Depth Information
Time for action - adding a tutorial
Let's move back to our createGameScreen method.
1. Inside that method, add the following lines to create our Label object:
_tutorialLabel = Label::createWithTTF("", "fonts/
Times.ttf", 60);
_tutorialLabel->setPosition(Vec2 (_screenSize.width *
0.5f, _screenSize.height * 0.6f) );
this->addChild(_tutorialLabel, kForeground);
_tutorialLabel->setVisible(false);
2. We add four states to our enumerated list of game states. These will represent the
different steps in our tutorial:
typedef enum {
kGameIntro,
kGamePlay,
kGameOver,
kGameTutorial,
kGameTutorialJump,
kGameTutorialFloat,
kGameTutorialDrop
} GameState;
The first tutorial state, kGameTutorial , acts as a separator from all other game
states. So, if the value for _state is greater than kGameTutorial , we are in
tutorial mode.
Now, depending on the mode, we display a different message and we wait on a dif-
ferent condition to change to a new tutorial state.
3. If you recall, our showTutorial method starts with a message telling the player
to tap the screen to make the sprite jump:
_tutorialLabel->setString ("Tap the screen to make the
player jump.");
_state = kGameTutorialJump;
Search WWH ::




Custom Search