Game Development Reference
In-Depth Information, .4, { y : height, onComplete:
parent.removeChild, onCompleteParams:[this] } );
When the rules panel becomes part of the display list, it anima-
tes itself in from the top of the screen. It also adds a listener to the
close button that reverses this animation and on completion
removes the panel from the Stage. Because there are no other
references to the panel than the display list, once it is removed
from the Stage, Flash will garbage-collect it. Now, we
re ready to
The Game Class
ve now reached the meat of the code is, so to speak. The Game
class is a composite of a few different components. The first and
most important is the GameBoard class, which we will review
shortly. The GameBoard controls the actual logic that keeps track
of each of the images, shuffles them, and determines whether or
not the puzzle has been completed. In addition, the Game class
stores an instance of whatever the source image is
in this case, a
still image from the library. Finally, this class manages all of the UI
relevant to the game, like the quit button and text fields. We
ll start
breaking it down with the variable declarations.
public class Game extends MovieClip {
static public const GAME_OVER:String = " gameOver " ;
public var piecesLeftText:TextField;
public var movesMadeText:TextField;
public var timeElapsedText:TextField;
public var quitButton:SimpleButton;
private var _sourceImage:ISourceImage;
private var _gameBoard:GameBoard;
private var _totalPieces:int;
private var _piecesLeft:int;
private var _movesMade:int;
private var _timeElapsed:int;
private var _timer:Timer;
public function Game() {
addEventListener(Event.ADDED_TO_STAGE, addedToStage,
false, 0, true);
Search Nedrilad ::

Custom Search