Game Development Reference
In-Depth Information
private function createExplode(size:int, xloc:int, yloc:int):void {
if (size==EXPLODE_SMALL) {
tempExplode = new BlitSprite(tileSheet, explodeSmallTiles, 0);
}else {
tempExplode = new BlitSprite(tileSheet, explodeLargeTiles, 0);
}
tempExplode.x = xloc;
tempExplode.y = yloc;
tempExplode.animationLoop = true;
tempExplode.useLoopCounter = true;
explosionList.push(tempExplode);
addChild(tempExplode);
}
Coding the object cleanup functions
The object cleanup functions are dispose and disposeAll .
The dispose function takes in a single BlitSprite (or its child, TileByTileBlitSprite ) and
removes it from the screen and readies it for garbage collection. It calls the internal dispose
function of the BlitSprite class and removes the object from the display list.
The disposeAll function calls dispose on all of the objects in the game. It is called at the end of
each level and at the end of the game.
private function dispose(object:BlitSprite):void {
object.dispose();
removeChild(object);
}
private function disposeAll():void {
dispose(player);
for each(tempEnemy in enemyList) {
dispose(tempEnemy)
}
enemyList = null;
for each(tempMissile in playerMissileList) {
dispose(tempMissile)
}
playerMissileList = null;
for each(tempMissile in enemyMissileList) {
dispose(tempMissile)
}
enemyMissileList = null;
for each(tempExplode in explosionList) {
dispose(tempExplode)
}
explosionList = null;
Search WWH ::




Custom Search