Class CompositeEntity<T>

A CompositeEntity is a special type of Entity that can contain multiple Blocks. Each block can have its own update function and properties, allowing for modular and reusable components within an entity.

T - The type of ICompositeEntityProps for the entity.

Type Parameters

Hierarchy (view full)

Constructors

Properties

action?: ((time: number, ctx: CanvasRenderingContext2D, properties: ICompositeEntityProps<any>, sequence?: Sequence, entity?: Canvas2DEntity<ICompositeEntityProps<any>>) => void)

The action function that defines the entity's behavior.

barListeners?: ((time: number, count: number, propertyBag?: ICompositeEntityProps<any>) => void)[] = []
beatListeners?: ((time: number, count: number, propertyBag?: ICompositeEntityProps<any>) => void)[] = []
canvas: HTMLCanvasElement
ctx: CanvasRenderingContext2D
durationInMs?: number
h?: number

The height of the entity's canvas.

name: string

The key or identifier for the entity.

The properties for the entity.

scene?: Scene
startTimeinMs?: number
tickListeners?: ((time: number, count: number, propertyBag?: ICompositeEntityProps<any>) => void)[] = []
transitionIn?: ((ctx: CanvasRenderingContext2D, progress: number) => void)
transitionOut?: ((ctx: CanvasRenderingContext2D, progress: number) => void)
w?: number

The width of the entity's canvas.

Methods

  • Adds a post-processing function to the entity.

    Parameters

    • processor: ((ctx: CanvasRenderingContext2D, sequence: Sequence) => void)

      The post-processing function to add.

        • (ctx, sequence): void
        • Parameters

          • ctx: CanvasRenderingContext2D
          • sequence: Sequence

          Returns void

    Returns void

  • Copies the entity's canvas to the target canvas and applies post-processors.

    Parameters

    • targetCanvas: HTMLCanvasElement

      The target canvas to copy to.

    • sequence: Sequence

      The Sequence instance.

    Returns void

  • Adds an event listener for when a bar is complete.

    Type Parameters

    • T

    Parameters

    • listener: ((ts: number, count: number, propertyBag?: T) => void)

      The function to call when a bar is complete.

        • (ts, count, propertyBag?): void
        • Parameters

          • ts: number
          • count: number
          • OptionalpropertyBag: T

          Returns void

    Returns this

    The Entity instance for chaining.

  • Adds an event listener for when a beat occurs.

    Type Parameters

    • T

    Parameters

    • listener: ((time: number, count: number, propertyBag?: T) => void)

      The function to call when a beat occurs.

        • (time, count, propertyBag?): void
        • Parameters

          • time: number
          • count: number
          • OptionalpropertyBag: T

          Returns void

    Returns this

    The Entity instance for chaining.

  • Adds an event listener for when a tick occurs.

    Type Parameters

    • T

    Parameters

    • listener: ((time: number, count: number, propertyBag?: T) => void)

      The function to call when a tick occurs.

        • (time, count, propertyBag?): void
        • Parameters

          • time: number
          • count: number
          • OptionalpropertyBag: T

          Returns void

    Returns this

    The Entity instance for chaining.

  • Updates the entity's state, clears the canvas, and calls the action function.

    Parameters

    • timeStamp: number

      The current timestamp in the animation.

    Returns void