@kayelaa/canvas API - v0.2.15
    Preparing search index...

    Class LeaEntityIIAbstract

    Abstract base class for all entities in a LEA scene.

    Provides event emission (update, draw, error), position, name, and z-order.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    listenerMap: Map<"error" | "draw" | "update", Listener<any[]>[]> = ...
    name: string = ""

    Unique name of the entity (used for lookup and serialization).

    scaleRotate: number = 0
    scale: number = 1
    arraySerializeMap?: LeaEntitySerializer<any>
    autoTranslate: boolean
    z: number

    Z-order for draw sorting (higher = drawn later / on top).

    ___pos: Vector2
    nonSerializableProperties: (string | number | symbol)[]
    forceSerializableProperties: (string | number | symbol)[]

    Accessors

    • get x(): number

      X coordinate (center).

      Returns number

    • set x(s: number): void

      Parameters

      • s: number

      Returns void

    • get y(): number

      Y coordinate (center).

      Returns number

    • set y(s: number): void

      Parameters

      • s: number

      Returns void

    Methods

    • Registers a listener for the specified event.

      Type Parameters

      • K extends "error" | "draw" | "update"

        Event name

      Parameters

      • event: K

        The name of the event

      • listener: (
            ...args: {
                update: [number];
                error: [unknown];
                draw: [CanvasRenderingContext2D];
            }[K],
        ) => void

        The callback to invoke when the event is emitted

      Returns this

      This emitter for chaining

    • Registers a one-time listener for the specified event.

      The listener is automatically removed after the first invocation.

      Type Parameters

      • K extends "error" | "draw" | "update"

        Event name

      Parameters

      • event: K

        The name of the event

      • listener: (
            ...args: {
                update: [number];
                error: [unknown];
                draw: [CanvasRenderingContext2D];
            }[K],
        ) => void

        The callback to invoke once

      Returns this

      This emitter for chaining

    • Removes a listener for the specified event.

      Type Parameters

      • K extends "error" | "draw" | "update"

        Event name

      Parameters

      • event: K

        The name of the event

      • listener: (
            ...args: {
                update: [number];
                error: [unknown];
                draw: [CanvasRenderingContext2D];
            }[K],
        ) => void

        The callback to remove

      Returns this

      This emitter for chaining

    • Emits an event, invoking all registered listeners with the provided arguments.

      If the event is "error" and no listeners are registered, the first argument (the error) will be thrown.

      Type Parameters

      • K extends "error" | "draw" | "update"

        Event name

      Parameters

      • event: K

        The name of the event to emit

      • ...args: { update: [number]; error: [unknown]; draw: [CanvasRenderingContext2D] }[K]

        Arguments to pass to listeners

      Returns boolean

      true if any listeners were invoked, false otherwise

    • Removes all listeners for the specified event, or all listeners if no event is provided.

      Type Parameters

      • K extends "error" | "draw" | "update"

        Event name

      Parameters

      • Optionalevent: K

        Optional event name to clear listeners for

      Returns LeaEntityII

      This emitter for chaining

    • Returns the number of listeners registered for the specified event.

      Type Parameters

      • K extends "error" | "draw" | "update"

        Event name

      Parameters

      • event: K

        The event to count listeners for

      Returns number

      The number of registered listeners

    • Update entity.

      Parameters

      • delta: number

      Returns void

    • Called once per tick with delta time (seconds).

      Parameters

      • _delta: number

      Returns void

    • Draw entity.

      Parameters

      • ctx: CanvasRenderingContext2D

      Returns void

    • Called once per frame to draw the entity.

      The context is already translated to the entity's position if autoTranslate is true.

      Parameters

      • ctx: CanvasRenderingContext2D

        The 2D rendering context

      Returns void

    • Serializes the entity to a plain object (for save/load).

      Excludes internal properties and respects nonSerializableProperties.

      Returns any

      Serializable data

    • Parameters

      • snapshot: any[]

      Returns any