Game Development Reference
In-Depth Information
complete, enemyMovementFinished is called. At the moment, all it
does is remove the enemy from memory, but in a full game it would
contain additional logic to cause damage when it hit if the player
was not on that side or deduct points from the player
enemy motion could also be handled by a moveEnemies method
that decrements the enemies
z position over time, but this method
hastwobigplusses.First,itis much easier to implement
one line
of code versus several. Second, and even more importantly, using a
tween gives much greater motion control. Notice that the tween
uses an easeIn function on the animation, which will make the
enemy slowly accelerate as it moves. This effect would be much
more troublesome to write manually and with very little return. Let
review the Game class in its entirety before we move on to the fun
linking these classes to an FLA and watching it run!
package tunnelshooter {
import flash.display.Sprite;
import flash.utils.Timer;
import flash.utils.Dictionary;
import gs.TweenLite;
import gs.easing.Quad;
public class Game extends Sprite {
static public var tunnelSize:Number = 175;
static public var tunnelDepth:int = 8;
static public var tunnelSides:int = 8;
static public var enemyFrequency:Number = 3;
static public var enemyTime:Number = 5;
protected var _tunnel:Tunnel;
protected var _player:Player;
protected var _angleIncrement:Number;
protected var _enemyFrequency:Number;
protected var _enemyTime:Number;
protected var _enemyCreator:Timer;
protected var _enemyList:Dictionary;
public function Game(){
_tunnel = new Tunnel(tunnelSize, tunnelDepth,
_player = new Player();
Search Nedrilad ::

Custom Search