dacha
    Preparing search index...

    Interface SystemAbstract

    Abstract base class for all game systems.

    Systems are the core logic units that operate on scenes and actors.

    class MovementSystem extends SceneSystem {
    private actorQuery: ActorQuery;
    private time: Time;

    constructor(options: SceneSystemOptions) {
    super();

    this.time = options.time;
    this.actorQuery = new ActorQuery({
    scene: options.scene,
    filter: [Transform, Velocity]
    });
    }

    update(): void {
    const { deltaTime } = this.time;
    const actors = this.actorQuery.getActors();

    for (const actor of actors) {
    const transform = actor.getComponent(Transform);
    const velocity = actor.getComponent(Velocity);

    transform.world.position.x += velocity.x * deltaTime;
    transform.world.position.y += velocity.y * deltaTime;
    }
    }
    }
    interface System {
        fixedUpdate?(): void;
        onSceneDestroy?(scene: Scene): void;
        onSceneEnter?(scene: Scene): void;
        onSceneExit?(scene: Scene): void;
        onSceneLoad?(scene: Scene): Promise<void>;
        update?(): void;
    }

    Hierarchy (View Summary)

    Index
    • Called with fixed timestep for physics calculations

      Returns void

    • Called when a scene is destroyed

      Parameters

      Returns void

    • Called when a scene becomes active

      Parameters

      Returns void

    • Called when a scene becomes inactive, but still remains in memory

      Parameters

      Returns void

    • Called when a scene is loaded. Used to load required resources for the system such as images, fonts, etc.

      Parameters

      Returns Promise<void>

    • Called every frame with variable timestep

      Returns void