Appearance
Class: Button
处理点击事件
ts
// 创建节点
const node = new Transform();
// 添加布局组件
const button = node.addComponent(Button);
const target = this;
function onClick() {
console.log('click');
button.remove(onClick, target);
}
// 添加点击事件
button.add(onClick, target)
// 放入父节点
parent.addChild(node);
Hierarchy
↳
Button
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new Button()
组件不能单独实例化,必须通过Transform.addComponent创建
ts
const node = new Transform();
const componet = node.addComponent(Component);
Inherited from
Defined in
src/core/component/Component.ts:37
Properties
callback
• callback: Map
<any
, Function
[]>
Defined in
src/core/component/Button.ts:62
difftime
• difftime: number
= 200
起落时间间隔
Defined in
src/core/component/Button.ts:60
emitter
• emitter: EventEmitter
<string
| symbol
, any
>
事件处理器
Inherited from
Defined in
src/core/component/Component.ts:27
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
Methods
add
▸ add(callback
, target
): void
Parameters
Name | Type |
---|---|
callback | Function |
target | any |
Returns
void
Defined in
src/core/component/Button.ts:64
destroy
▸ destroy(): void
消毁
Returns
void
Inherited from
Defined in
src/core/component/Component.ts:55
onDestroy
▸ Optional
onDestroy(): void
组件被销毁时触发
Returns
void
Inherited from
Defined in
src/core/component/Component.ts:62
remove
▸ remove(callback
, target
): void
Parameters
Name | Type |
---|---|
callback | Function |
target | any |
Returns
void
Defined in
src/core/component/Button.ts:73
start
▸ start(): void
组件被挂载到节点时触发
Returns
void
Overrides
Defined in
src/core/component/Button.ts:24
update
▸ Optional
update(time
): void
每帧调用
Parameters
Name | Type | Description |
---|---|---|
time | number | 和上一帧的间隔时间 ms |
Returns
void