Game Development Reference
In-Depth Information
The constructor and the init method are shown below:
public function Game()
{
super();
}
public override function init():void {
super.init();
m_discard = new Discard();
m_countDown = new CountDownTimer();
m_countDown.addEventListener(CountDownTimerEvent.DONE,
onTimerUp);
m_countDown.x = 550;
m_countDown.y = 230;
m_pulse = PulseGame.getInstance().getGameClient();
m_mgr = new CardManager(this);
m_frogs = new Array();
m_frogs.push(new Frog(Color.BLUE, m_map,
Asset.getBlueRacer()));
m_frogs.push(new Frog(Color.RED, m_map,
Asset.getRedRacer()));
m_frogs.push(new Frog(Color.PURPLE, m_map,
Asset.getPurpleRacer()));
m_frogs.push(new Frog(Color.GREEN, m_map,
Asset.getGreenRacer()));
m_frogs.push(new Frog(Color.YELLOW, m_map,
Asset.getYellowRacer()));
m_map = new Map();
}
Assigning colors
When the game begins, we first need to assign each player a different color. For this
we call the request color within the start method:
private function requestColor():void {
var index:int;
index = (Math.random()*1000)%m_colors.length;
var color:ColorCard;
color = m_colors[index];
var gsm:PlayerColorClient;
gsm = new PlayerColorClient();
gsm.setStateKey("color-"+color.color);
 
Search WWH ::




Custom Search