An abstract pattern for primary layers of the game canvas to implement.

Abstract

Hierarchy (view full)

Properties

options: {
    name: string;
} = ...

Options for this layer instance.

Type declaration

  • name: string
#drawing: Promise<CanvasLayer> = ...

An internal reference to a Promise in-progress to draw the CanvasLayer.

#drawn: boolean = false

Is the layer drawn?

Accessors

  • get name(): string
  • The canonical name of the CanvasLayer is the name of the constructor that is the immediate child of the defined baseClass for the layer type.

    Returns string

    Example

    canvas.lighting.name -> "LightingLayer"
    
  • get hookName(): string
  • The name used by hooks to construct their hook string. Note: You should override this getter if hookName should not return the class constructor name.

    Returns string

  • get layerOptions(): {
        name: string;
    }
  • Customize behaviors of this CanvasLayer by modifying some behaviors at a class level.

    Returns {
        name: string;
    }

    • name: string

Methods

  • Draw the canvas layer, rendering its internal components and returning a Promise. The Promise resolves to the drawn layer once its contents are successfully rendered.

    Parameters

    • Optional options: object = {}

      Options which configure how the layer is drawn

    Returns Promise<CanvasLayer>

  • Deconstruct data used in the current layer in preparation to re-draw the canvas

    Parameters

    • Optional options: object = {}

      Options which configure how the layer is deconstructed

    Returns Promise<CanvasLayer>

  • Protected

    The inner _draw method which must be defined by each CanvasLayer subclass.

    Parameters

    • options: object

      Options which configure how the layer is drawn

    Returns Promise<void>

    Abstract

  • Protected

    The inner _tearDown method which may be customized by each CanvasLayer subclass.

    Parameters

    • options: object

      Options which configure how the layer is deconstructed

    Returns Promise<void>