Game Development Reference
In-Depth Information
else {
displayResult(false);
}
if ( m_pulse.isGameHost() )
m_pulse.finishGame();
}
2.
We will apply the fade effect to the result sprite and set up the
onRestartGame callback to be called after the fade effect is done.
private function displayResult(win:Boolean):void {
var r:WinLoose;
r = new WinLoose(win);
r.x = 400-(r.width/2);
r.y = 300-(r.height/2);
addChild(r);
var sd:SpriteDissolve;
sd = SpriteDissolve.createSpriteDissolve(this, r);
sd.play();
sd.addEventListener(SpriteDissolveEvent.DONE,
onRestartGame);
m_pulse.playerReady(false);
}
3.
Once the fade effect is done, we will start the game. We will remove the
current track from the screen, create a new racetrack, and call the start game.
private function onRestartGame(e:Event):void {
removeChild(m_track);
m_track.stopRace();
m_track = new RaceTrack(m_stage, m_pulse);
m_track.setShipMask(m_myMask, m_pulse.getMyAvatar());
addChild(m_track);
m_pulse.playerReady(true);
if ( m_pulse.isGameHost() )
m_pulse.startGame();
}
4.
The race begins for everyone once the server broadcasts the game start
message. This time around, we simply add the track to the screen and go!
public override function startGame():void {
if ( m_firstTime ) {
super.startGame();
 
Search WWH ::




Custom Search