Game Development Reference
In-Depth Information
projectileManager.projectiles.push(tempProjectile);
projectileManager.lastProjectileShot=0;
}else {
projectileManager.lastProjectileShot+=step;
}
}
Also notice that we add the step value to projectileManager.lastProjectileShoot counter instead of
the standard 1 per frame tick. This way, we keep the fire rate of the player timed to the step timer
rather than the frame rate. If we tied it directly to the frame tick rate, users on faster machines
would get to fire more often in the same time frame than users on slower machines. In our game,
each player will fire the same number of projectiles each second no matter what frameRate the
game is played at.
Now, we are going to take a look at the checkCollisions functions:
private function checkCollisions():void {
mineManager.mineCount = mineManager.mines.length - 1;
projectileManager.projectileCount = projectileManager.projectiles.length - 1;
mines: for (var mineCtr:int = mineManager.mineCount; mineCtr >= 0; mineCtr--) {
tempMine=mineManager.mines[mineCtr];
tempMine.point.x=tempMine.x;
tempMine.point.y=tempMine.y;
projectiles: for (var projectileCtr:int=projectileManager.projectileCount;
projectileCtr>=0;projectileCtr--) {
tempProjectile=projectileManager.projectiles[projectileCtr];
tempProjectile.point.x=tempProjectile.x;
tempProjectile.point.y=tempProjectile.y;
//use pixel hit because circle circle for
//these was causing false negatives on ship shield hit
if (tempProjectile.bitmapData.hitTest(tempProjectile.point,255,
tempMine.bitmapData,tempMine.point,255)) {
dispatchEvent(new CustomEventSound(CustomEventSound.PLAY_SOUND,
Main.SOUND_MINE_EXPLODE, false, 0, 8, 1));
createExplode(tempMine.x+16, tempMine.y+16, particleManager.
particlesPerExplode*frameRateMultiplier);
tempMine=null;
mineManager.mines.splice(mineCtr, 1);
tempProjectile.frame = 0;
projectileManager.projectilePool.push(tempProjectile);
projectileManager.projectiles.splice(projectileCtr,1);
score += 5 * level;
Search WWH ::




Custom Search