Game Development Reference
In-Depth Information
Alternatively, you could place dynamic text fields inside the clips
and update them with the score. They are also cached as bitmaps
because they will live underneath other cached elements. Text in
particular has rendering performance lag when layered between
GPU-cached elements. You
but wait, the con-
tents of the clip will change whenever the player scores, causing
Flash to redraw it.
re probably thinking
cess will take place when the game is not active, so there will be
no noticeable hiccup. The alternative would be to not cache it and
have it slow down the whole game considerably
not the best
The third layer,
ve created to act as
the borders of the table. The physics system will translate these boxes
(with the help of our engine) into mathematical constructs. This
allows us to fine-tune the layout of elements visually without adjust-
ing numbers in code. Note that each of these clips is named. Since
there are a limited number of them, I simply reference them later
on in the Game class. If the number of clips grew or had no limit,
I would apply the same method of crawling the display list that I
used in Marble Runner. However, because that involves the creation
of unnecessary stub classes, I
contains box clips I
ve omitted that process here. The
layer contains the puck and both paddles. Finally,
the top-most layer holds the GameTouchController objects we looked
at earlier. Now we
Game Objects
re ready to dive into the code for this sucker. We
start by examining the member variables and constants.
public class Game extends Sprite
static public const STATE_PRE_GAME:int = 1;
static public const STATE_GAME_ACTIVE:int = 2;
static public const STATE_GAME_SCORE:int = 3;
static public const STATE_POST_GAME:int = 4;
static public const MAX_SCORE:int = 3;
static private const OVERLAY_PRE_GAME_COUNTDOWN:String =
static private const OVERLAY_PLAYER_1_SCORE:String =
static private const OVERLAY_PLAYER_2_SCORE:String =
static private const OVERLAY_PLAYER_1_WON:String =
" Player1Won " ;
static private const OVERLAY_PLAYER_2_WON:String =
" Player2Won " ;
Search Nedrilad ::

Custom Search