Constructor
new Engine()
Example
#Creating a new engine.
const engine = new Engine({
interval: 16,
});
- Mixes In:
Parameters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
config.interval |
number |
<optional> |
16 | The number of milliseconds between executions. |
Methods
addEntities(…entities) → {Engine}
Adds all specified entities to the engine.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
entities |
entities |
<repeatable> |
The entities. |
Throws
- ReferenceError
- Will throw this error if invoked after the engine has been disposed.
addSystems(…systems) → {Engine}
Adds all specified systems to the engine.
getState() → {string}
Get the engine state.
Throws
- ReferenceError
- Will throw this error if invoked after being disposed.
Returns
The engine state.
- Type
- string
init() → {Promise}
Initializes the engine and all registered systems.
Fires:
- Engine#event:initialize
Throws
- ReferenceError
- Will throw this error if invoked after the engine has been disposed.
- Error
- Will throw this error when the engine is not capable of being initialized.
Returns
The engine initialization.
- Type
- Promise
removeEntities(…entitiesOrIds) → {Engine}
Removes all specified entities from the engine.
start() → {Promise}
Starts the engine loop.
Fires:
- Engine#event:start
- Engine#event:idle
- Engine#event:stop
- Engine#event:tick
Throws
- ReferenceError
- Will throw this error if invoked after the engine has been disposed.
- Error
- Will throw this error when the engine is not capable of being started.
Returns
The engine start.
- Type
- Promise