Game Development Reference
In-Depth Information
public var nextY:Number = 0;
public var dx:Number=0;
public var dy:Number = 0;
private var doCopyPixels:Boolean = false;
public var loopCounter:int = 0;
// counts the number of animation loops if useCounter is set to true;
public var useLoopCounter:Boolean = false;
public function BlitSprite(tileSheet:TileSheet, tileList:Array, firstFrame:int) {
this.tileSheet = tileSheet;
tileWidth = tileSheet.tileWidth;
tileHeight = tileSheet.tileHeight;
this.tileList = tileList;
rect = new Rectangle(0, 0, tileWidth, tileHeight);
point = new Point(0, 0);
bitmapData = new BitmapData(tileWidth, tileHeight, true, 0x00000000);
bitmap = new Bitmap(bitmapData);
bitmap.x = -.5 * tileWidth;
bitmap.y = -.5 * tileHeight;
addChild(bitmap);
currentTile = firstFrame;
renderCurrentTile(true );
}
public function updateCurrentTile():void {
if (animationLoop) {
if (animationCount > animationDelay) {
animationCount = 0;
currentTile++;
doCopyPixels = true;
if (currentTile > tileList.length - 1) {
currentTile = 0;
if (useLoopCounter) loopCounter++;
}
}
animationCount++;
}
}
public function renderCurrentTile(forceCopyPixels:Boolean=false):void {
if (forceCopyPixels) {
doCopyPixels = true;
}
Search WWH ::




Custom Search