EventCenter.ts
714 Bytes
import { EventEnum } from "./EventEnum";
/*
* name;
*/
export class EventCenter {
private static _instance: Laya.EventDispatcher;
private static get I(): Laya.EventDispatcher {
window['ev'] = this._instance;
return this._instance || (this._instance = new Laya.EventDispatcher);
}
public static emit(event: EventEnum, ...args) {
this.I.event(event.toString(), args);
}
public static add(type: EventEnum, caller: any, listener: Function, args?: Array<any>) {
this.I.on(type.toString(), caller, listener, args);
}
public static remove(type: EventEnum, caller: any, listener: Function) {
this.I.off(type.toString(), caller, listener);
}
}