Class: Layer

PIXI.layers.Layer

A layer can be used to render PIXI.DisplayObjects in a different part of the scene graph together.

A layer can be used to structure a scene graph in a data-oriented manner and separate the z-ordering hierarchy in a different tree. Each layer is associated with a Group that provides the context for sorting objects in the same layer.

All layers must be placed underneath a Stage - generally, you should assign a Stage as your scene's root.

new PIXI.layers.Layer (group)

Name Type Default Description
group PIXI.layers.Group undefined

The group of DisplayObjects to be rendered by this layer.

Extends

  • Container

Members

clearColor ArrayLike<number>

The background color to clear the layer.

This should be used when Layer#useRenderTexture is enabled.

The group of DisplayObjects that are rendered within this layer

Default Value:
  • undefined

isLayer boolean readonly

Flags that this container is a layer!

Default Value:
  • true

The texture manager used when rendering into a layer render-texture.

useDoubleBuffer boolean

This will enable double buffering for this layer.

This layer will keep two render-textures to render into - choosing one each frame on a flip-flop basis. This is useful when you

Caveat: You must enable Layer#useRenderTexture to prevent framebuffer errors in rendering.

useRenderTexture boolean

Flags whether this layer should render into a render-texture.

This is useful if you want to use the layer as a texture elsewhere - for example, in sprites or to apply filters. The layer's render-texture is resized to the size of the renderer's screen.

Methods

destroy (options) void

Name Type Attributes Description
options IDestroyOptions <optional>

doSort () void

you can override this method for this particular layer, if you want

getRenderTexture () RenderTexture

The rendering into a render-texture is enabled, this will return the render-texture used by this layer.

Returns:
Type Description
RenderTexture

layerRenderCanvas (renderer) void

renderCanvas named this way because of some TS mixin problem

Name Type Description
renderer any

render (renderer) void

Name Type Description
renderer Renderer

postrender (renderer) void protected

Cleans up the renderer after this layer is rendered.

It restores Renderer#_activeLayer to the parent layer and restores the canonical order of children.

Name Type Description
renderer ILayeredRenderer

prerender (renderer) boolean protected

Prepares the renderer for this layer.

It will assign PIXI.Renderer#_activeLayer to this, and set the active layer before this to _activeParentLayer. It will also temporarily sort the children by z-order.

Name Type Description
renderer ILayeredRenderer
Returns:
Type Description
boolean true, if the layer needs to be rendered; false, when the layer is invisible or has zero alpha.