Extends
- EventEmitter
Members
(private) entities :Object
Declared entities
Type:
- Object
(private) systems :Array.<System>
Declared systems
Type:
- Array.<System>
(private) systemVsEntities :Object
Entities associated to systems
Type:
- Object
Methods
entity(name) → {Entity}
Declare a new entity
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of the new entity |
Returns:
The newly created entity object
- Type
- Entity
getEntity(name) → {Entity}
Returns existing entity
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of the entity |
Returns:
The entity object or undefined if not found
- Type
- Entity
getSystem(name) → {System}
Returns existing system
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of the system |
Returns:
The system object or undefined if not found
- Type
- System
removeEntity(name)
Remove a entity from the engine instance
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the entity to be removed |
removeSystem(name)
Remove a system from the engine instance
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the system to be removed |
system(name, components, handler) → {System}
Declare a new system.
The handler function receives two arguments, the name of the entity and a object
of components.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of the new system |
components |
Array.<string> | Names of the components the new system will operate on |
handler |
function | System function |
Returns:
The newly created system object
- Type
- System
tick() → {Number}
Run a single execution step.
Emit a TICK_BEFORE event before running the systems and a TICK_AFTER event after running them.
Returns:
Current simulation time
- Type
- Number
(private) updateSystemsVsEntities()
Scan systems and search for suitable entities to be associated.