Appearance
Class: Rect
矩形绘制,必须挂载Graphics节点上才能生效
ts
const node = app.stage.addChild(new Transform(Graphics));
node.position.set(100, 100);
node.size.set(100, 100);
const rect = node.addComponent(Rect)!;
rect.radius = 10;
rect.fill = '#0000FF';
rect.storke = '#ff0000';
rect.storkeWidth = 3;
Hierarchy
↳
Rect
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new Rect()
组件不能单独实例化,必须通过Transform.addComponent创建
ts
const node = new Transform();
const componet = node.addComponent(Component);
Inherited from
Defined in
src/core/component/Component.ts:37
Properties
emitter
• emitter: EventEmitter
<string
| symbol
, any
>
事件处理器
Inherited from
Defined in
src/core/component/Component.ts:27
fill
• Optional
fill: string
= '#000000'
填充颜色
Defined in
id
• id: number
用于表示组件的唯一标识
Inherited from
Defined in
src/core/component/Component.ts:12
name
• name: string
= ''
组件名
Inherited from
Defined in
src/core/component/Component.ts:17
node
组件挂载节点
Inherited from
Defined in
src/core/component/Component.ts:22
radius
• radius: number
= 0
圆角大小
Defined in
storke
• storke: string
= '#FFFFFF'
边框颜色
Defined in
storkeWidth
• storkeWidth: number
= 0
边框大小
Defined in
Methods
destroy
▸ destroy(): void
消毁
Returns
void
Inherited from
Defined in
src/core/component/Component.ts:55
onDestroy
▸ onDestroy(): void
组件被销毁时触发
Returns
void
Overrides
Defined in
start
▸ start(): void
组件被挂载到节点时触发
Returns
void
Overrides
Defined in
update
▸ update(time
): void
每帧调用
Parameters
Name | Type | Description |
---|---|---|
time | number | 和上一帧的间隔时间 ms |
Returns
void