Game Development Reference
In-Depth Information
Designing the game screen
The heart of any game—this is where all the action takes place. Because this is where
the game will be implemented, most code is written here to implement the game.
The standard init, show, and hide methods must be overridden and implemented
to initialize, add, and remove the needed sprites respectively. In addition to the
three methods, let us examine a few other methods that get called when we need
to implement.
If the game is designed for players to join after the game has already started, the
game code should not wait for the startGame method to be called. Instead, the show
method must check if the game has already started and update the game screen with
all the game states that it receives.
The method startGame gets called when the host starts the game; this method gets
called in all the clients that are in the room. In this method, we begin the race in case of
a racing game or we start distributing the cards in the case of a card game, and so on.
The show method must additionally check if the player is the game host. If so, then
the game screen should show the start sprite and for all other players (non-hosts) the
player should show wait sprite.
Finally, in case the game has not started and the host quits the room for some reason,
the method onHostAlert would be called. In this case, the player that becomes the
host must have the wait sprite replaced with the start sprite.
 
Search WWH ::




Custom Search