@moxijs/core - v0.3.4
    Preparing search index...

    Class MoxiEntity<T>

    Manages logic components attached to a PIXI object. Usually accessed via entity.moxiEntity after calling asEntity().

    const sprite = asEntity(new PIXI.Sprite(texture));
    sprite.moxiEntity.addLogic(new MyLogic());
    sprite.moxiEntity.getLogic<MyLogic>('MyLogic').speed = 10;

    Type Parameters

    • T
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    entity: T

    The PIXI object this entity wraps.

    logic: MoxiLogic<T> = {}

    Attached logic components keyed by name.

    Methods

    • Attach a logic component to this entity.

      Parameters

      • logic: Logic<T>

        The logic component to attach. Uses logic.name or class name as key.

      Returns void

    • Get a logic component by name.

      Type Parameters

      Parameters

      • name: string

        The name of the logic component (class name or custom name)

      Returns L

      The logic component, or undefined if not found

    • Calls init() on all logic components. Called automatically when scene.init() is invoked.

      Parameters

      • renderer: Renderer<HTMLCanvasElement>

        The PIXI renderer

      • ...args: any[]

        Additional arguments passed through to logic.init()

      Returns void

    • Calls update() on all active logic components. Called automatically by Scene each frame.

      Parameters

      • deltaTime: number

        Time since last frame in frames (1 = 1/60s at 60fps)

      Returns void