Game Development Reference
In-Depth Information
public function createParticlePool(maxParticles:int):void {
particlePool = [];
particles = [];
for (var particleCtr:int=0;particleCtr<maxParticles;particleCtr++) {
var tempParticle:BasicBiltArrayParticle = new BasicBiltArrayParticle(0,799,0,799);
particlePool.push(tempParticle);
}
}
A new pool of Particle instances is created for each level. The number of objects in this pool is
based on the maxParticles value passed in.
Now, look at the particleManager.createLevelParticles function:
public function createLevelParticles(spriteGlowFilter:GlowFilter, levelColor:uint):void {
var tempBlitArrayAsset:BlitArrayAsset = new BlitArrayAsset();
particleBitmapData = new BitmapData(8, 8, true, 0x00000000);
drawingCanvas.graphics.clear();
drawingCanvas.graphics.lineStyle(1, 0xffffff);
drawingCanvas.graphics.drawRect(3, 3, 2, 2);
particleBitmapData.draw(drawingCanvas);
spriteGlowFilter.color = levelColor;
particleBitmapData.applyFilter(particleBitmapData, particleBitmapData.rect,
point0, spriteGlowFilter);
tempBlitArrayAsset= new BlitArrayAsset();
tempBlitArrayAsset.createFadeOutBlitArrayFromBD(particleBitmapData, 30);
particleAnimationFrames = tempBlitArrayAsset.tileList;
}
The appearance of the particles is based on the levelColor for the Mine s. That color is passed
into the function along with the BlasterMines spriteGlowFilter instance. The particles use the
BlitArrayAsset class's createFadeOutArrayFrameBD to create an array of faded frames. When
played in succession over a number of frame ticks, the particles will appear to fade and burn out
as they move away from the center of the explosion.
Search WWH ::




Custom Search