Game Development Reference
In-Depth Information
package com.efg.games.flakcannon
{
import flash.display.Shape;
import flash.display.Sprite
import flash.events.MouseEvent;
import flash.display.Bitmap;
import flash.display.BitmapData;
public class Ship extends Sprite
{
public var imageBitmapData:BitmapData;
public var image:Bitmap;
/*
//**Flex Framework Only
[Embed(source = "assets/flakassets.swf", symbol="ShipGif")]
private var ShipGif:Class;
*/
public function Ship() {
init();
}
public function init():void {
//***** Flex *****
//imageBitmapData = new ShipGif().bitmapData;
//**** Flash *****
imageBitmapData = new ShipGif(0, 0);
image = new Bitmap(imageBitmapData);
addChild(image);
}
public function dispose():void {
removeChild(image);
imageBitmapData.dispose();
image = null;
}
}
}
Creating objects that move on a continuous vector: Enemy
Unlike BonusPlane and Ship , Enemy has some major differences from the Shot class. Some of
them come from the fact that we simulate three different types of Enemy planes with one class. We
do this by supporting three directions for the Enemy planes: DIR_DOWN , DIR_RIGHT , or DIR_LEFT . The
other major change is more substantial. We could have created the movement code in Enemy the
same way we created the movement code in both Shot and BonusPlane . Instead though, we will
introduce a new algorithm for movement that can support an object moving in almost any
direction using an angle.
Search WWH ::




Custom Search