Game Development Reference
In-Depth Information
Managing Lives and the GameOver process
To follow from this point, you can simply open the file BreakaWall-
step3.gameproj .
To make the game more realistic, you can give the player three lives. This means
that the third time the ball is missed, you will display a Game Over message and
the player will not be able to spawn a new actor. You will also display a Retry
button that will reset the scene and let the player attempt to win again.
As you may have guessed already, you will use an attribute to manage the lives.
Every time the ball is missed, you will decrement the attribute by 1. You will add
a condition to check that the number of lives is strictly superior to 0 before
spawning a new ball. In the display text, you will have a rule to display the Game
Over message when the lives attribute is equal to 0.
Time to GameSalad design! Create a new integer attribute, rename it ''lives'',
and set the default value to 3. Your attribute will look like Figure 4-27.
Figure 4-27. Lives attribute
Open the Ball actor in the Actor Editor by double-clicking it. In the Losing Zone
rule, drag and drop a Change Attribute behavior and position it between the
game.ActiveBall Change Attribute behavior and the Destroy behavior. Modify
game.lives to game.lives-1.
The Losing Zone rule will be as in Figure 4-28.
 
Search WWH ::




Custom Search