arcade2d
Class

Layer

graphics/layer.ts:24

One render layer in a LayerSet — a lightweight, world-agnostic token that names a band in the draw order and remembers where it sits in that order.

A Layer carries no rendering state of its own. It is an identity: a game defines its layers once via defineLayers, then passes the resulting tokens to graphics components (GraphicsOptions.layer). Each Scene maps these tokens onto its own Pixi sub-containers, so the same Layer can describe the draw order of any number of worlds without holding a reference to any of them.

The Layer.setId brand records which LayerSet minted the token, so a Scene can reject a token that belongs to a different set (ErrorCode.LAYER_NOT_IN_SET) rather than silently mis-layering a graphic.

Construct layers with defineLayers, never new Layer — the factory is the only supported way to mint a set and its tokens together.

Properties

readonly #
name: string

The layer's name — the key LayerSet.get looks it up by.

readonly #
order: number

Its position in the set's back-to-front order; 0 is drawn first (furthest back).

readonly #
setId: symbol

The identity of the owning LayerSet, used to reject tokens from a foreign set. Not meaningful to game code.

Layers are minted by LayerSet; do not call directly.

ESC