Graphics Reference
In-Depth Information
ALERT!
If you are creating a custom event class that extends Event, remember
that it
s very important to override the clone function. By overriding the
clone function, you allow the event to be redispatched if needed.
'
The MemoryGame Class (the Game Engine)
And now for the core of this chapter and the engine of the game
itself: the MemoryGame class. The MemoryGame class uses an
array of images that are passed in to create, shuffle, and deal the
cards. It also handles user interactions, checks for card matches/
mismatches and game completions, and sends out a notification of
each event using the MemoryGameEvent class.
MemoryGame Code
package com.flashadbook.engines{
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.utils.getDefinitionByName;
import flash.utils.setTimeout;
import com.flashadbook.DeckArray;
import com.flashadbook.events.MemoryGameEvent;
public class MemoryGame extends MovieClip{
public const GRID_LAYOUT:String = " gridLayout " ;
public const CUSTOM_LAYOUT:String = " customLayout " ;
private var _cardsToCompare:Array = new Array();
private var _memoryCards:DeckArray = new
DeckArray();
private var _numberOfCards:uint;
private var _cardPadding:int;
private var _matchesComplete:int;
private var _tempCard:Class;
private var _frontBmd:BitmapData;
private var _frontSkin:Bitmap;
private var _tempCardBack:Class;
private var _backBmd:BitmapData;
private var _backSkin:Bitmap;
Search WWH ::




Custom Search