Layer
This class extends Displayble
You can manage the layers of the displayables by using the Layer class.
Usage
import {Layer} from "narraleaf-react";const layer = new Layer("layer name", {
zIndex: 1
});
const scene = new Scene("scene with layers", {
layers: [layer] // register the layer to the scene
});
const image = new Image({ /* ... */}).useLayer(layer); // link the image to the layerlayer.opacity(0.5, 1000, "linear"); // change the opacity of the layer, all elements linked to the layer will be affectedSince 0.26.0, a layer does not carry its pose out of the scene that declared it. Leaving a
scene now returns the layers that scene put on stage to their configured z-index and pose, not
only the displayables standing on them, and newGame() does the same. Before that, a layer slid
aside or faded out stayed that way for every scene that followed. The story
Camera is deliberately exempt: a story owns exactly
one and it frames the stage across scene changes.
Chainable Methods
setZIndex
Set the z-index of the layer. Higher z-index means the layer will be on top of the other layers.
zIndex: number- The z-index of the layer
Public Methods
constructor
name?: string- The name of the layerconfig?: Partial<ILayerUserConfig>- The configuration of the layer, see ILayerUserConfig