Game Development Reference
In-Depth Information
To indicate that the ship's shields are up, we add a filter to the ship sprite.
private function shieldUp():void {
m_shieldOn = true;
var filts:Array = this.filters;
filts.push(m_shieldFilter);
this.filters = filts;
m_shieldTime = m_maxShieldTime;
}
When the update is called from the main game loop, we decrement the remaining
shield time, and when it goes down to zero, we turn off the shield. Here again is a
great scope for powering the ship's shield-up time, depending on the ship and if
it has acquired any items that increase the shield time.
public function update(timeLenMilli:int):void {
m_trackPosX += m_speed;//*timeLenMilli;
if ( m_shieldOn ) {
m_shieldTime -= timeLenMilli;
if ( m_shieldTime <= 0 ) {
shieldDown();
}
}
}
private function shieldDown():void {
m_shieldOn = false;
var filts:Array = this.filters;
filts.pop();
this.filters = filts;
}
Finishing the race
The race is finished when the last quadrant is loaded. Whoever loads it up, wins the
race. When the main game loop detects the end, we unload all quadrants and turn on
the Boolean variable to indicate that the race is over. We will also slap on the finish
screen sprite. After the race is over, we stop calling any update methods and simply
return from the game loop.
private function gameLoop(event:TimerEvent):void {
processUserInput();
if ( m_gameEnd )
return;
m_map.update(m_ship, false);
var cqi:int = m_ship.getCoord()/QUADRANT_LENGTH;
 
Search WWH ::




Custom Search