Game Development Reference
In-Depth Information
timeString += String(seconds);
}
timeElapsedText.text = timeString;
}
This set of six methods comprises the accessor, or getter/setter,
methods that we
ll use for this class. The get function simply
returns the value of the private variable. The set function sets the
private variable and also updates the corresponding TextField
object. In the case of the timeElapsed property, in particular, the
time must be updated from just a number of seconds to a standard
formatting of
'
mm:ss.
public function init(sourceImage:ISourceImage,
rows:int,
columns:int,
imageWidth:int = 0,
imageHeight:int = 0,
boardPosition:Point = null):void {
_totalPieces = piecesLeft = rows * columns;
movesMade = 0;
_sourceImage = sourceImage;
_gameBoard = new GameBoard(_sourceImage, GamePiece, rows,
columns, imageWidth, imageHeight);
if (!boardPosition) boardPosition = new Point();
_gameBoard.x = boardPosition.x;
_gameBoard.y = boardPosition.y;
_gameBoard.createBoard();
addChildAt(_gameBoard, 0);
_gameBoard.shuffleBoard();
}
public function startGame():void {
_gameBoard.activate();
_gameBoard.addEventListener(GameBoard.GAME_OVER,
pauseBeforeGameOver, false, 0, true);
_gameBoard.addEventListener(GameBoard.PIECE_SWAP,
pieceSwap, false, 0, true);
_gameBoard.addEventListener(GameBoard.PIECE_LOCK,
pieceLock, false, 0, true);
timeElapsed = 0;
_timer.start();
}
You may have noticed that these two public methods are the
same two called by the MixUp class earlier. The init function sets
upthegameforplay,andstartGame activates the GameBoard
for mouse input and starts the Timer. There are a number of
Search Nedrilad ::




Custom Search