Skip to content
On this page

Class: Mask

mask遮罩
在主节点上挂载一个mask,设置为mask.value的节点将不会被展示出来或激活参与其它动态布局计算,且必须将其设置为子节点

ts
// 创建节点
const node = new Transform();
// 添加遮罩
const mask = node.addComponent(Mask);
mask.value = node.addChild(new Transform());
// 放入父节点
parent.addChild(node);

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Mask()

组件不能单独实例化,必须通过Transform.addComponent创建

ts
const node = new Transform();
const componet = node.addComponent(Component);

Inherited from

Component.constructor

Defined in

src/core/component/Component.ts:37

Properties

emitter

emitter: EventEmitter<string | symbol, any>

事件处理器

Inherited from

Component.emitter

Defined in

src/core/component/Component.ts:27


id

id: number

用于表示组件的唯一标识

Inherited from

Component.id

Defined in

src/core/component/Component.ts:12


name

name: string = ''

组件名

Inherited from

Component.name

Defined in

src/core/component/Component.ts:17


node

node: Transform<Container>

组件挂载节点

Inherited from

Component.node

Defined in

src/core/component/Component.ts:22


renew

renew: boolean = true

是否需要重绘

Defined in

src/core/component/Mask.ts:24


texture

Optional texture: Texture<TextureResource>

最终效果的纹理,这样设计不影响原节点和蒙版节点

Defined in

src/core/component/Mask.ts:32


value

Optional value: Transform<Container>

遮罩蒙版

Defined in

src/core/component/Mask.ts:28

Methods

destroy

destroy(): void

消毁

Returns

void

Inherited from

Component.destroy

Defined in

src/core/component/Component.ts:55


onDestroy

Optional onDestroy(): void

组件被销毁时触发

Returns

void

Inherited from

Component.onDestroy

Defined in

src/core/component/Component.ts:62


start

start(): void

组件被挂载到节点时触发

Returns

void

Overrides

Component.start

Defined in

src/core/component/Mask.ts:34


update

Optional update(time): void

每帧调用

Parameters

NameTypeDescription
timenumber和上一帧的间隔时间 ms

Returns

void

Inherited from

Component.update

Defined in

src/core/component/Component.ts:50