Game Development Reference
In-Depth Information
private function disposeAll():void {
particleManager.particleCount = particleManager.particles.length-1
// remove particle pool
for (var ctr:int = particleManager.particleCount; ctr >= 0; ctr--) {
tempParticle = particleManager.particles.pop();
tempParticle.frame = 0;
particleManager.particlePool.push(tempParticle);
}
//remove particle animation
for (ctr= 0; ctr < particleManager.particleAnimationFrames.length; ctr++) {
particleManager.particleAnimationFrames[ctr].dispose();
}
particleManager.particleAnimationFrames = null;
particleManager.particleBitmapData = null;
particleManager.particlePool = null;
trace("disposed");
//remove mines
for (ctr= 0; ctr < mineManager.mineAnimationFrames.length; ctr++) {
mineManager.mineAnimationFrames[ctr].dispose();
}
mineManager.mineAnimationFrames = null;
mineManager.mines = null;
mineManager.mineBitmapData = null;
if (gameOver) {
playerExplosionParticles = null;
}
}
The disposeAll function up the objects between levels and at the end of each game. This saves
memory by freeing them up for the garbage collection process.
The full GameFrameWork class
For reference, we have included the entire new com.efg.framework.GameFrameWork.as file in this
section. Many changes have been made to this file in this chapter. We recommend that you
replace the current GameFrameWork.as file with this one. We did not cover every line of each
change in the earlier sections. Pay close attention to the comments that that show the changes in
chapter 11.
Search WWH ::




Custom Search