Game Development Reference
In-Depth Information
public class Enemy extends MovieClip {
public var index:int;
protected var _brightness:Number;
public function Enemy(index:int) {
this.index = index;
public function get brightness ():Number {
return _brightness;
public function set brightness (value:Number):void {
_brightness = value;
var ct:ColorTransform = transform.colorTransform;
ct.redMultiplier = ct.greenMultiplier =
Multiplier = _brightness;
transform.colorTransform = ct;
Since an enemy in this style of game generally sticks to one side
of the tunnel, we keep track of which side through the index prop-
erty, which is passed in when the enemy is created. The other
method is a getter/setter combo that set the brightness value of the
s colorTransform. This has the opposite effect of the tint we
used on the tiles. It will allow us to make the enemy darker the
further down the tunnel it is, and make it brighter as it approaches
the player.
We are now ready to look at the Game class, and the logic that
will control the player and the enemies.
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;
Search Nedrilad ::

Custom Search