文档
图层

图层

此类继承自 Displayble

你可以使用 Layer 类来管理可显示元素的图层。

用法

import {Layer} from "narraleaf-react";
const layer = new Layer("图层名称", {
    zIndex: 1
});
 
const scene = new Scene("带有图层的场景", {
    layers: [layer] // 将图层注册到场景中
});
 
const image = new Image({ /* ... */}).useLayer(layer); // 将图像链接到图层
layer.opacity(0.5, 1000, "linear"); // 更改图层的不透明度,所有链接到图层的元素都会受到影响

公共方法

constructor

  • name?: string - 图层的名称
  • config?: Partial<ILayerUserConfig> - 图层的配置,参见 ILayerUserConfig

include

将可显示元素包含到图层中

  • elements: (Image | Text)[] | Image | Text - T要包含的可显示元素,例如 Image, Text
  • 返回 this