Game Development Reference
In-Depth Information
(int(Math.random() * 2) == 0)? tempObstacle.y = playfieldminY : tempObstacle.y =
(playfieldmaxY - tempObstacle.height);
}
tempObstacle.x = playfieldmaxX;
obstacles.push(tempObstacle);
addChild(tempObstacle);
}
//update obstacles
var obstacleCount:int = obstacles.length - 1;
for (var ctr:int=obstacleCount;ctr>=0;ctr--) {
tempObstacle= obstacles[ctr];
tempObstacle.x -= obstacleSpeed*timeBasedModifier;
if (tempObstacle.x < playfieldminX) {
tempObstacle.scaleY = 1;
tempObstacle.scaleX = 1;
obstaclePool.push(tempObstacle);
obstacles.splice(ctr, 1);
removeChild(tempObstacle);
}
}
var exhaustPoolCount:int = exhaustPool.length -1;
if (getTimer() > (lastExhaustTime + exhaustDelay) && exhaustPoolCount > 0 ) {
lastExhaustTime = getTimer();
tempExhaustParticle = exhaustPool.pop();
tempExhaustParticle.lifeDelayCount=0;
tempExhaustParticle.x=playerSprite.x-30;
tempExhaustParticle.y = playerSprite.y-32;
tempExhaustParticle.nextX=tempExhaustParticle.x;
tempExhaustParticle.nextY=tempExhaustParticle.y;
tempExhaustParticle.speed = obstacleSpeed;
tempExhaustParticle.frame = 0;
tempExhaustParticle.animationList = exhaustAnimationList;
tempExhaustParticle.bitmapData =
tempExhaustParticle.animationList[tempExhaustParticle.frame];
tempExhaustParticle.dx = -1;
tempExhaustParticle.dy = 0;
tempExhaustParticle.lifeDelay = 3;
exhaustParticles.push(tempExhaustParticle);
}
exhaustLength = exhaustParticles.length - 1;
canvasBitmapData.lock();
for (ctr = exhaustLength; ctr >= 0; ctr--) {
tempExhaustParticle = exhaustParticles[ctr];
//dirty rect blit erase
blitPoint.x = tempExhaustParticle.x;
blitPoint.y = tempExhaustParticle.y;
canvasBitmapData.copyPixels(backgroundBitmapData,
tempExhaustParticle.bitmapData.rect, blitPoint);
if (tempExhaustParticle.update(timeBasedModifier)) {
tempExhaustParticle.frame = 0;
exhaustPool.push(tempExhaustParticle);
Search WWH ::




Custom Search