Class: EntitySystem

EntitySystem

EntitySystems allow for more complex component-based logic. Using getEntitySet, all entities with a certain component can be retrieved. so they can update with knowledge of each-other, or of other components. (for example a HunterComponent vs PreyComponent). Other uses are if an external engine (physics, or so) needs to be updated. EntitySystems need to be started through Scene#startSystem, where a strict order of updates is enforced. Systems are always updated in the order they were added, and after regular components have been updated.


new EntitySystem()

Author:
  • derschmale <http://www.derschmale.com>

Methods


getEntitySet(components)

Retrieves an EntitySet containing entities matching the given components.

Parameters:
Name Type Description
components

An Array of component types.


onStarted()

Called when a system is started.


onStopped()

Called when a system is stopped. Anything changed by the system should be undone here.


onUpdate(dt)

Called when a system needs to update.

Parameters:
Name Type Description
dt

The time in milliseconds since last update.