Skip to main content

Class: LayerService

Defined in: rendering/layer-service.ts:21

The LayerService class manages the creation, registration, and resizing of render layers.

Implements

Constructors

Constructor

new LayerService(game): LayerService

Defined in: rendering/layer-service.ts:29

Constructs a new instance of the LayerService class.

Parameters

game

Game

Returns

LayerService

Methods

getLayer()

getLayer<T>(name): T

Defined in: rendering/layer-service.ts:55

Retrieves a render layer by its name.

Type Parameters

T

T extends RenderLayer

Parameters

name

string

The name of the layer.

Returns

T

The RenderLayer instance.

Throws

An error if the layer is not found.


registerLayer()

registerLayer(layer): void

Defined in: rendering/layer-service.ts:45

Registers an existing canvas element as a render layer.

Parameters

layer

RenderLayer

The render layer.

Returns

void

The registered RenderLayer instance.


resizeAllLayers()

resizeAllLayers(dimensions?): void

Defined in: rendering/layer-service.ts:69

Resizes all registered layers to the specified dimensions.

Parameters

dimensions?

Vector2

The new dimensions for the layers. If not provided, the window dimensions are used.

Returns

void


stop()

stop(): void

Defined in: rendering/layer-service.ts:81

Cleans up the layer service by removing the resize event listener.

Returns

void

Implementation of

Stoppable.stop