Game Development Reference
In-Depth Information
public class PlatformerEngine extends Sprite {
protected var _gravity:Vector3D;
protected var _friction:Number;
protected var _config:PlatformerConfig;
protected var _currentLevel:XML;
protected var _previousTime:int;
protected var _deltaTime:Number;
protected var _keyLeftPressed:Boolean;
protected var _keyRightPressed:Boolean;
protected var _walls:Array;
protected var _items:Array;
protected var _enemies:Array;
protected var _portals:Array;
protected var _player:IPlayer;
protected var _collisionGrid:CollisionGrid;
protected var _gameRunning:Boolean = false;
protected var _inventory:Vector.
;
protected var _assetDomain:ApplicationDomain;
protected var _assetPath:String =
<
IItem
>
;
protected var _assetQueue:Vector. < String > = new Vector.
< String > ();
protected var _assets:Vector. < Loader > = new Vector. < Loader > ();
""
public function PlatformEngine() {
}
The properties listed here mostly consist of containers for differ-
ent types of objects. A couple of important things to note are the
container for the player
s inventory and the _assetDomain property.
The latter is used to store all the class definitions for the assets the
engine will load. This will keep those definitions from overriding any
that might exist in the engine but will keep them from being sepa-
rated from each other. Note that the constructor does nothing
'
it is
there merely as an acknowledgment. Initialization is handled
through the init method, which we will look at next.
public function init(config:PlatformerConfig):void {
_config = config;
_gravity = _config.gravity;
_friction = _config.friction;
_assetDomain = new ApplicationDomain(ApplicationDomain.
currentDomain);
_inventory = new Vector. < IItem > ();
}
This method handles creation of a number of basic engine
properties. It is the first of a handful of public-facing methods.
Search Nedrilad ::




Custom Search