Game Development Reference
In-Depth Information
Determining the initial frog positions
The frog positions are assigned by the game host during the start method. The start
method is listed below:
private function start():void {
m_endRound = false;
if ( m_pulse.isGameHost() ) {
shuffleFrogs();
// send the frog positions
var i:int;
var f:Frog;
for ( i=0; i<m_frogs.length; i++) {
f = m_frogs[i];
var fp:FrogClient;
fp = new FrogClient();
fp.setPosition(i);
fp.setFrog(f.color);
m_pulse.addGameState(fp);
}
}
// Choose Color.
m_colors = m_mgr.copyColors();
// Send a color request
requestColor();
// Get first three cards
getCard();
m_discard.x = 130;
m_discard.y = 400;
addChild(m_discard);
}
When the Frog game state is received, we process it as follows:
public function
processFrogPos(gameState:GameStateClient):void {
var gs:FrogClient;
gs = gameState as FrogClient;
var f:Frog;
f = getFrogWithColor(gs.getFrog());
m_map.addFrog(f);
}
 
Search WWH ::




Custom Search