Skip to content

Latest commit

 

History

History
80 lines (49 loc) · 1.83 KB

System.md

File metadata and controls

80 lines (49 loc) · 1.83 KB

retro-engine / Exports / System

Class: 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;
    });
  }
}

Table of contents

Constructors

Properties

Methods

Constructors

constructor

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.

Properties

component

Abstract component: ComponentType<Component>

The component that this system acts on.

Defined in

src/ecs.ts:205

Methods

update

Abstract update(entities): void

This function is run once per frame.

Parameters

Name Type Description
entities Set<GameObjectBase> The list of entities that the system acts on.

Returns

void

Defined in

src/ecs.ts:211