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 affectedChainable 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
This is how depth between layers is controlled, and the comparison is applied before the order of elements inside any one layer. To reorder elements that share a layer, use Displayable.bringToFront.
Public Methods
constructor
name?: string- The name of the layerconfig?: Partial<ILayerUserConfig>- The configuration of the layer, see ILayerUserConfig
include
Include the displayable to the layer.
bringToFront
Not available on a layer. Layer inherits this method from Displayable, but calling it throws a RuntimeGameError while the story is being built.
A layer is not an entry in another layer's list of elements, so it has no front to be moved to. Use setZIndex to raise a layer instead.
layer.setZIndex(10); // this is how a layer moves forward
layer.bringToFront(); // RuntimeGameError