Game Development Reference
In-Depth Information
animation has finished. When it does finish, the game checks to
see if either player has reached the maximum score for the game,
defined at the beginning as a constant value of 3. If neither player
has reached the maximum score, the engine is reset and the game
goes back to the active state. If a player has won, the game goes to
its final state of POST_GAME.
private function onPostGameEnter():void
{
var overlayClass:Class;
if ( mPlayer1Score > mPlayer2Score )
{
overlayClass = Class( getDefinitionByName( OVERLAY_
PLAYER_1_WON ) );
}
else
{
overlayClass = Class( getDefinitionByName( OVERLAY_
PLAYER_2_WON ) );
}
mOverlayClip = new overlayClass() as MovieClip;
mOverlayClip.cacheAsBitmap = true;
addChild(mOverlayClip);
}
private function onPostGameUpdate( _dt:Number ):void
{
if (mOverlayClip.currentFrame == mOverlayClip.totalFrames )
{
removeChild( mOverlayClip );
mOverlayClip = null;
dispose();
Main.getInstance().gotoAndStop( Main.FRAME_TITLE );
}
}
an overlay is dis-
played showing the winner, and after that animation has finished
playing, the game disposes of itself and returns to the title screen.
That
All of this should look familiar at this point
s the extent of the Game class. Before diving into the engine
class, where we
'
'
'
s take a quick
look at the Time class I created earlier. It is generic enough that
you can use it in any project.
ll roll up our sleeves with physics, let
public class Time extends Sprite
{
static public const FPS24:Number = 1/24;
static public const FPS30:Number = 1/30;
Search Nedrilad ::




Custom Search