Packageash.core
Classpublic class Engine
InheritanceEngine Inheritance Object
Subclasses SwiftSuspendersEngine

The Engine class is the central point for creating and managing your game state. Add entities and systems to the engine, and fetch families of nodes from the engine.



Public Properties
 PropertyDefined By
  entities : Vector.<Entity>
[read-only] Returns a vector containing all the entities in the engine.
Engine
  familyClass : Class
The class used to manage node lists.
Engine
  systems : Vector.<System>
[read-only] Returns a vector containing all the systems in the engine.
Engine
  updateComplete : Signal0
Dispatched when the update loop ends.
Engine
  updating : Boolean
Indicates if the engine is currently in its update loop.
Engine
Public Methods
 MethodDefined By
  
Engine
  
addEntity(entity:Entity):void
Add an entity to the engine.
Engine
  
addSystem(system:System, priority:int):void
Add a system to the engine, and set its priority for the order in which the systems are updated by the engine update loop.
Engine
  
getEntityByName(name:String):Entity
Get an entity based n its name.
Engine
  
getNodeList(nodeClass:Class):NodeList
Get a collection of nodes from the engine, based on the type of the node required.
Engine
  
getSystem(type:Class):System
Get the system instance of a particular type from within the engine.
Engine
  
releaseNodeList(nodeClass:Class):void
If a NodeList is no longer required, this method will stop the engine updating the list and will release all references to the list within the framework classes, enabling it to be garbage collected.
Engine
  
Remove all entities from the engine.
Engine
  
Remove all systems from the engine.
Engine
  
removeEntity(entity:Entity):void
Remove an entity from the engine.
Engine
  
removeSystem(system:System):void
Remove a system from the engine.
Engine
  
update(time:Number):void
Update the engine.
Engine
Property Detail
entitiesproperty
entities:Vector.<Entity>  [read-only]

Returns a vector containing all the entities in the engine.


Implementation
    public function get entities():Vector.<Entity>
familyClassproperty 
public var familyClass:Class

The class used to manage node lists. In most cases the default class is sufficient but it is exposed here so advanced developers can choose to create and use a different implementation. The class must implement the Family interface.

systemsproperty 
systems:Vector.<System>  [read-only]

Returns a vector containing all the systems in the engine.


Implementation
    public function get systems():Vector.<System>
updateCompleteproperty 
public var updateComplete:Signal0

Dispatched when the update loop ends. If you want to add and remove systems from the engine it is usually best not to do so during the update loop. To avoid this you can listen for this signal and make the change when the signal is dispatched.

updatingproperty 
public var updating:Boolean

Indicates if the engine is currently in its update loop.

Constructor Detail
Engine()Constructor
public function Engine()



Method Detail
addEntity()method
public function addEntity(entity:Entity):void

Add an entity to the engine.

Parameters

entity:Entity — The entity to add.

addSystem()method 
public function addSystem(system:System, priority:int):void

Add a system to the engine, and set its priority for the order in which the systems are updated by the engine update loop.

The priority dictates the order in which the systems are updated by the engine update loop. Lower numbers for priority are updated first. i.e. a priority of 1 is updated before a priority of 2.

Parameters

system:System — The system to add to the engine.
 
priority:int — The priority for updating the systems during the engine loop. A lower number means the system is updated sooner.

getEntityByName()method 
public function getEntityByName(name:String):Entity

Get an entity based n its name.

Parameters

name:String — The name of the entity

Returns
Entity — The entity, or null if no entity with that name exists on the engine
getNodeList()method 
public function getNodeList(nodeClass:Class):NodeList

Get a collection of nodes from the engine, based on the type of the node required.

The engine will create the appropriate NodeList if it doesn't already exist and will keep its contents up to date as entities are added to and removed from the engine.

If a NodeList is no longer required, release it with the releaseNodeList method.

Parameters

nodeClass:Class — The type of node required.

Returns
NodeList — A linked list of all nodes of this type from all entities in the engine.
getSystem()method 
public function getSystem(type:Class):System

Get the system instance of a particular type from within the engine.

Parameters

type:Class — The type of system

Returns
System — The instance of the system type that is in the engine, or null if no systems of this type are in the engine.
releaseNodeList()method 
public function releaseNodeList(nodeClass:Class):void

If a NodeList is no longer required, this method will stop the engine updating the list and will release all references to the list within the framework classes, enabling it to be garbage collected.

It is not essential to release a list, but releasing it will free up memory and processor resources.

Parameters

nodeClass:Class — The type of the node class if the list to be released.

removeAllEntities()method 
public function removeAllEntities():void

Remove all entities from the engine.

removeAllSystems()method 
public function removeAllSystems():void

Remove all systems from the engine.

removeEntity()method 
public function removeEntity(entity:Entity):void

Remove an entity from the engine.

Parameters

entity:Entity — The entity to remove.

removeSystem()method 
public function removeSystem(system:System):void

Remove a system from the engine.

Parameters

system:System — The system to remove from the engine.

update()method 
public function update(time:Number):void

Update the engine. This causes the engine update loop to run, calling update on all the systems in the engine.

The package net.richardlord.ash.tick contains classes that can be used to provide a steady or variable tick that calls this update method.

Parameters

time:Number