Game Development Reference
In-Depth Information
if (PulseGame.getInstance().
getGameClient().isMyTurn() == true)
removeChild(m_turnSprite);
}
m_isGaming = false;
}
In this game, there could only be two players. So what happens when one of the
players simply closes the browser or gets disconnected from the server? In this case,
we terminate the game and move the remaining player to the lobby. The player
may also actively jump to the lobby initiating the game termination. If the game has
started, we remove the game board; we also check if the Your Turn sprite is being
displayed and remove that as well.
The lobbyHit method is called when the player chooses to quit the game screen. At
this point, we simply end the game. For this particular game implementation, there is
no point in having one player stay in the room after the other player has quit. So, as
soon as one player quits, we send the remaining player to the lobby.
protected override function lobbyHit():void {
if ( m_isGaming )
m_tictactoeGame.getGameClient().finishGame();
super.lobbyHit();
}
Now that we have seen screen management for the game board, we will see how the
game plays out.
Displaying player turn
Recall that this method is called from our subclass of PulseGame object instance.
When the server indicates that it is the player's turn to play, we show the Your Turn
sprite to the player.
public function onPlayerTurn():void {
// show the turn indicator
m_showingTurn = true;
addChild(m_turnSprite);
}
 
Search WWH ::




Custom Search