/**
 * 全局侦听类及消息处理
 */
export  class DisPatcherOn extends Laya.EventDispatcher
{
    public static ins:DisPatcherOn;
    private _dispatcher:Laya.EventDispatcher;
    private isInit:boolean = false;
    public constructor(){
        super();
        DisPatcherOn.ins = this;
        if(this.isInit){             
        }
        if(this._dispatcher == null){
            this._dispatcher = new Laya.EventDispatcher();
            this.isInit = true;
        }
    }

    public static get Instance():DisPatcherOn{
        if(DisPatcherOn.ins==null)
            return new DisPatcherOn();
        return DisPatcherOn.ins;
    }

    public addEventListener(type:string,listener:Function,thisObject:any,useCapture:boolean=false,priority:number=0):void{
        this._dispatcher.on( type,thisObject, listener);
    }

    public removeEventListener(type:string,listener:Function,thisObject:any,useCapture:boolean=false):void{
        this._dispatcher.off( type,thisObject, listener );
    }

    public hasEventListener(type:string):boolean
    {
        return this._dispatcher.hasListener(type);
    }

    public dispatchEvent(type:string,data?: any):boolean {
        return this._dispatcher.event(type,data);
    }
}