Game Development Reference
In-Depth Information
When init() is called, the only real difference is the Bitmapdata we use to create the image. This
time it is PlaneBonusGif()
public function init():void
{
x = startLocation.x;
y = startLocation.y;
var xd:Number = endLocation.x - x;
var yd:Number = endLocation.y - y;
var Distance:Number = Math.sqrt(xd*xd + yd*yd)
moves = Math.floor(Math.abs(Distance/speed));
xunits = (endLocation.x - x)/moves;
yunits = (endLocation.y - y)/moves;
//***** Flex *****
//imageBitmapData = new PlaneBonusGif().bitmapData;
//***** Flash *****
imageBitmapData = new PlaneBonusGif(0,0);
image = new Bitmap(imageBitmapData);
addChild(image);
finished = false;
}
The rest of the functions from Shot remain essentially the same in BonusPlane .
public function update():void {
if (moves > 0) {
nextLocation.x = x + xunits;
nextLocation.y = y + yunits;
moves--;
} else {
finished = true;
}
}
public function render():void {
x = nextLocation.x;
y = nextLocation.y;
}
public function dispose():void {
removeChild(image);
imageBitmapData.dispose();
image = null;
}
}
}
Ship
Now we will discuss the Ship object. Ship is the easiest Sprite class because Ship s do not move
in Flak Cannon. They truly are static sprites! They simple stay in place, waiting to be destroyed
(err, defended). That means that the only real differences are the Flex embed and the fact that we
use ShipGif() to get our Bitmapdata .
Search WWH ::




Custom Search