Game Development Reference
In-Depth Information
In the game implementation as it is, we simply assign masks depending on the order
in which the players enter the room. But for a real game, there is a lot of scope for
these masks to be purchased. Creating a different base ship, you can still apply the
same masks to create a wide variety of ships.
The code that applies the mask to the ship's base image is listed as follows:
public function SpaceShip(m:int, av:GameAvatarClient) {
super();
m_mask = m;
m_av = av;
var colors:Array = new Array();
colors.push(0xFFFF00);
m_shieldFilter = new GlowFilter(0xFFFF00);
var bma:BitmapAsset;
bma = new Ship() as BitmapAsset;
var bmd:BitmapData;
bmd = bma.bitmapData;
// Get the mask data
var mask:BitmapAsset;
if ( m_mask == 0 )
mask = new Mask() as BitmapAsset;
else if ( m_mask == 1 )
mask = new Mask1() as BitmapAsset;
else if ( m_mask == 2 )
mask = new Mask2() as BitmapAsset;
var maskBMD:BitmapData = mask.bitmapData;
// Create a BMD to blend ship and the mask
var pd:BitmapData = new BitmapData(128, 48, true, 0);
var rect:Rectangle = new Rectangle(0, 0, 128, 48);
pd.copyPixels(maskBMD, rect,
new Point(0, 0), bmd,
new Point(0, 0), true);
 
Search WWH ::




Custom Search