Java Reference
In-Depth Information
Game Life Cycle
All applications, including games, require some sort of life cycle that moves the user from a starting
screen to each feature in the application. In Figure 11-8 we can see the life cycle of Clown Cannon. When
the game is first launched, the start screen is displayed. From the start screen the user can either view
the about screen or play the game. The game screen, in turn, allows the user to play again, which means
staying on the game screen, or go back the start screen. This is a very rudimentary application life cycle,
but it is complicated enough to require some set-up code. Listing 11-1 shows how the game sets itself up.
Figure 11-8. Game life cycle
Listing 11-1. Main.fx
public def random = new Random();
public var startScreen = GameAssetsUI{}
var aboutScreen = GameAssetsUI{}
var gameModel:GameModel;
var rootGroup = Group{
content: startScreen
onKeyReleased: keyReleased;
}
var scene = Scene {
width: 640
height: 480
content: [rootGroup]
fill: Color.BLACK
}
 
Search WWH ::




Custom Search