Game Development Reference
In-Depth Information
public function createProjectiles(spriteGlowFilter:GlowFilter):void {
//projectileManager.projectiles
var tempBlitArrayAsset:BlitArrayAsset = new BlitArrayAsset();
drawingCanvas.graphics.clear();
drawingCanvas.graphics.lineStyle(1, 0xffffff);
drawingCanvas.graphics.drawRect(3, 3, 2, 2);
projectileBitmapData.draw(drawingCanvas);
projectileBitmapData.applyFilter(projectileBitmapData, projectileBitmapData.rect,
point0, spriteGlowFilter);
tempBlitArrayAsset= new BlitArr`ayAsset();
projectileAnimationFrames=tempBlitArrayAsset.createRotationBlitArrayFromBD
(projectileBitmapData, 10,0);
}
Projectiles are drawn in a very similar manner to the player's ship. These are a simple rectangle
with a blue GlowFilter (spriteGlowFilter) to match the ship's glow.
Here is the
projectileManager.createProjectilePool
function:
public function createProjectilePool(maxProjectiles:int):void {
for (var projetcileCtr:int = 0; projetcileCtr < maxProjectiles; projetcileCtr++) {
var tempProjectile:BasicBiltArrayProjectile=new BasicBiltArrayProjectile(0,799,0,799);
tempProjectile.animationList=projectileAnimationFrames;
tempProjectile.bitmapData = tempProjectile.animationList[0];
projectilePool.push(tempProjectile);
}
}
The
projectilePool
is very similar to the particle pool described earlier. There are two
Array
s
that hold the projectiles. The
projectilePool
holds the inactive projectiles, and the
projectiles
Array
holds the active projectiles that are in use.
Adding the newGame and newLevel functions
The
BlasterMines.as
newGame
function sets up the defaults for a new game. The new level
functions set up a new level based on a simple algorithm to change the color, speed, and number
of enemy the player must face.
override public function newGame():void {
//cannot do this until the game has been added to the stage.
if (frameRateMultiplier==2) {
stage.quality = StageQuality.BEST;
}else {
stage.quality = StageQuality.MEDIUM;
}
trace("new game");