Game Development Reference
In-Depth Information
public interface IGamePiece extends IEventDispatcher {
//DisplayObject Properties
function get x():Number;
function set x(value:Number):void;
function get y():Number;
function set y(value:Number):void;
function get width():Number;
function set width(value:Number):void;
function get height():Number;
function set height(value:Number):void;
//GamePiece-specific Methods
function select():void;
function deselect():void;
function activate():void;
function deactivate():void;
function movePiece(x:Number, y:Number):void;
function lock():void;
//GamePiece-specific Accessors
function get image():BitmapData;
function set image(value:BitmapData):void;
function get index():int;
function set index(value:int):void;
function get currentIndex():int;
function set currentIndex(value:int):void;
}
}
This interface has considerably more definitions in it because
unlike the source images, these game pieces will also need to be
DisplayObjects. Because there is no common interface for Dis-
playObject classes to extend from, we
ll need to define some of
the basic properties that a game piece will need to have. These
include x and y position, as well as width and height. For conve-
nience, because the pieces will also need to dispatch events, we
can extend IEventDispatcher to keep us from having to retype all
thosemethods.Forthegamelogic,everypiecemusthaveaway
to be selected, deselected, activated, deactivated, moved, and
locked. They must also have properties that define the Bitmap-
Data displayed inside them, and their original and current
positions on the game board. We
'
ll look at the classes that
implement these interfaces shortly, but now that we at least
know how these objects will be defined, we
'
'
ll move on to the
GameBoard class.
Search Nedrilad ::




Custom Search