Game Development Reference
In-Depth Information
We see that if the login was successful, we can continue with the initialization for
the rest of the game screens. This happens in the
init
method. The
init
method
first draws the outline, which serves the background for the entire game and never
changes; other game screens are laid on top of the outline. The
init
method after
drawing the outline then initializes all the other screens. The following is how the
init
method looks in the
PulseGame
class:
protected function init():void {
// Show the outline
drawOutline();
// init other screens
initLobbyScreen();
initGameScreen();
initNewGameScreen();
initHiScoreScreen();
initRegisterScreen();
postInit();
}
Each of the
init
methods may be overridden to create our versions of the screen. For
example, a custom lobby screen may be created by overriding the
initLobbyScreen
.
The outline, in addition to drawing the background, also shows the player's own
avatar representation. We may provide our own implementation of the outline by
simply overriding the
initOutline
method.
The final step of the
init
method is the
postInit
, which the subclass may override
to perform any additional tasks or drawing required for the game. The default
implementation of the
postInit
requests the server to take the player to the lobby.
Exploring the Hello World sample
In the following sections, we will explore parts of the Hello World sample,
specifically dealing with the initial start-up phase.
HelloGame.as
The main class called
HelloGame
inherits from PulseGame, which is defined in
PulseUI. In the constructor of the class, we initialize the Skinner instance that
provides buttons and background for the game sample.
public function HelloGame() {
s_instance = this;
initSkinner();