Game Development Reference
In-Depth Information
gsm.setColor(color.color);
m_pulse.addGameState(gsm);
trace("Requesting Color: " + color.color);
}
The request color attempts to add a PlayerColor. We also set the state key so that the
game state is treated as a unique game state. If we receive the PlayerColor game state
and the sender ID is self, we set the color of this player.
public function
processPlayerColor(gameState:GameStateClient,
error:Boolean):void {
var color:PlayerColorClient;
color = (gameState as PlayerColorClient);
// if error then try another available color
// ...
// If not error
// If mine, init color
// else, remove the option
if ( error ) {
trace("Error on Color: " + color.getColor());
removeColor(color.getColor());
requestColor();
}
else {
if ( color.getSenderId() ==
m_pulse.getMyAvatar().getId() ) {
m_myColor = m_mgr.getColor(color.getColor());
m_myColor.x = 550;
m_myColor.y = 120;
addChild(m_myColor);
}
else {
removeColor(color.getColor());
}
}
}
The previous method is called from the onNewGameState method or from
onGameStateError . The Boolean flag error determines the case.
The onNewGameState implementation is shown next:
public function onNewGameState(gameState:GameStateClient):void {
var type:int;
 
Search WWH ::




Custom Search