import EventDispatcher = cc.EventTarget;
export class CustomEventMgr {
static eventDispatcher: EventDispatcher = new cc.EventTarget();
static _Ins: CustomEventMgr;
public static getIns(): CustomEventMgr {
if (CustomEventMgr._Ins == null) {
CustomEventMgr._Ins = new CustomEventMgr();
}
return CustomEventMgr._Ins;
}
constructor() {
}
/**
*
*
* @param {*} eventName //发送事件名字
* @param {any[]} [arg] //发送事件的参数
* @memberof CustomEventMgr
*/
public Emit(eventName, arg?: any[]) {
CustomEventMgr.eventDispatcher.emit(eventName, arg);
}
/**
*
* @param {*} eventName 注册事件名字
* @param {*} callback 触发事件后回调函数
* @param {any[]} [arg] 调用回调的目标(此对象),如果没有给定,则只删除没有目标的回调
* @memberof CustomEventMgr
*/
public on(eventName, callback, arg?: any[]) {
CustomEventMgr.eventDispatc
creator自定义事件管理
最新推荐文章于 2023-10-25 01:02:32 发布