diff --git a/assets/core/common/timer/TimerManager.ts b/assets/core/common/timer/TimerManager.ts index 840ab0b..9d19aaa 100644 --- a/assets/core/common/timer/TimerManager.ts +++ b/assets/core/common/timer/TimerManager.ts @@ -74,7 +74,7 @@ export class TimerManager extends Component { } } */ - register(object: any, field: string, onSecond: Function, onComplete: Function): any { + register(object: any, field: string, onSecond: Function, onComplete: Function): string { var timer = new Timer(); timer.step = 1; diff --git a/assets/module/common/GameComponent.ts b/assets/module/common/GameComponent.ts index 1cd8e43..19598ef 100644 --- a/assets/module/common/GameComponent.ts +++ b/assets/module/common/GameComponent.ts @@ -4,7 +4,7 @@ * @LastEditors: dgflash * @LastEditTime: 2022-12-13 11:36:00 */ -import { Asset, Component, EventKeyboard, EventTouch, Input, Node, __private, _decorator, input } from "cc"; +import { Asset, Button, Component, EventKeyboard, EventTouch, Input, Node, __private, _decorator, input } from "cc"; import { oops } from "../../core/Oops"; import { EventDispatcher } from "../../core/common/event/EventDispatcher"; import { EventMessage, ListenerFunc } from "../../core/common/event/EventMessage"; @@ -233,6 +233,7 @@ export class GameComponent extends Component { this.setButtonList(args); } protected setButtonList(args: string[]) { + // 自定义按钮批量绑定触摸事件 this.node.on(Node.EventType.TOUCH_END, (event: EventTouch) => { var self: any = this; var func = self[event.target.name]; @@ -241,6 +242,18 @@ export class GameComponent extends Component { else console.error(`名为【${event.target.name}】的按钮事件方法不存在`); }, this); + + // Cocos Creator Button组件批量绑定触摸事件 + var buttons = this.node.getComponentsInChildren