retro-engine / Exports / System
Represents a system that acts on a specific component. Systems are added automatically to the engine when a component is added to an entity.
Note that currently for a system to be added automatically its name must be the same as the component it acts on.
Example
An example user-defined game object:
import VelocityComponent from "./Velocity.js";
class Velocity extends engine.System {
static arg_names = [];
static arg_types = [];
component = VelocityComponent;
update(entities) {
entities.forEach(entity => {
entity.Position.x += entity.Velocity.x;
entity.Position.y += entity.Velocity.y;
});
}
}• new System()
The constructor function can be freely overridden and additional properties can be added to the system, as long as the arg_names and arg_types are updated accordingly.
• Abstract component: ComponentType<Component>
The component that this system acts on.
▸ Abstract update(entities): void
This function is run once per frame.
| Name | Type | Description |
|---|---|---|
entities |
Set<GameObjectBase> |
The list of entities that the system acts on. |
void