Game Development Reference
In-Depth Information
tempEnemy.missileDelay = enemyShotDelay;
tempEnemy.healthPoints = enemyHealthPoints;
addChild(tempEnemy);
enemyList.push(tempEnemy);
break;
Now, add in the
AMMO
,
GOAL
, and
LIVES
sprite case branches:
case SPRITE_AMMO:
tempPickup = new BlitSprite(tileSheet, [ammoFrame], 0);
tempPickup.x=(colCtr * tileWidth)+(.5*tileWidth);
tempPickup.y = (rowCtr * tileHeight) + (.5 * tileHeight);
addChild(tempPickup);
ammoPickupList.push(tempPickup);
break;
case SPRITE_GOAL:
goalSprite = new BlitSprite(tileSheet, [goalFrame], 0);
goalSprite.x=(colCtr * tileWidth)+(.5*tileWidth);
goalSprite.y = (rowCtr * tileHeight) + (.5 * tileHeight);
addChild(goalSprite);
break;
case SPRITE_LIVES:
tempPickup = new BlitSprite(tileSheet, [livesFrame], 0);
tempPickup.x=(colCtr * tileWidth)+(.5*tileWidth);
tempPickup.y = (rowCtr * tileHeight) + (.5 * tileHeight);
addChild(tempPickup);
lifePickupList.push(tempPickup);
break;
These three sprite types are all handled in a similar manner to the enemy and player sprites. The
difference is that they are instances of the
BlitSprite
class rather than the
TileByTileBlitSprite
class. These don't have to move about the maze; they simply remain
stationary.
Changing the checkLineOfSight function
We need to make one small change to the
checkLineOfSight
function. We previously used a
placeholder local variable for the
enemyIntelligence
value. We can now remove that placeholder,
because we read in a global
enemyInteligence
value in the
readBackGroundData
function. Please
make sure to find the line below (under
//**placeholder
) and comment it out or remove it entirely:
//**placeholder
//var enemyIntelligence:int = 50;
Adding the createExplode function
The
createExplode
function is used to create both the smaller explosion that displayed when a
wall or tank is hit and the larger explosion when one is destroyed. The function takes in three
parameters. The first is an integer constant that represents the size:
EXPLODE_SMALL
or
EXPLODE_LARGE
. The second is the
x
location, and the final is the
y
location. Explosions are added
to the
explosionList
array.