import { EventEmitter } from "eventemitter3" ; import * as PIXI from "pixi.js" ; let PIXIInteractionEvent = PIXI . InteractionEvent ; if ( ( < any > PIXI ) . interaction != undefined ) { PIXIInteractionEvent = ( < any > PIXI ) . interaction . InteractionEvent ; } export class InteractionEvent extends PIXIInteractionEvent { } export class EventManager { private static event = new EventEmitter ( ) ; public static NET_ERROR : string = "net_error" ; public static NET_RECOVER : string = "net_recover" ; public static TOUCH_CLICK : string = "tap" ; public static TOUCH_START : string = "touchstart" ; public static TOUCH_MOVE : string = "touchmove" ; public static TOUCH_END : string = "touchend" ; public static TOUCH_CANCEL : string = "touchendoutside" ; public static MOUSE_CLICK : string = "click" ; public static MOUSE_DOWN : string = "mousedown" ; public static MOUSE_MOVE : string = "mousemove" ; public static MOUSE_UP : string = "mouseup" ; public static MOUSE_UPOUTSIDE : string = "mouseupoutside" ; public static ALL_CLICK : string = "tap+click" ; public static ALL_START : string = "touchstart+mousedown" ; public static ALL_MOVE : string = "touchmove+mousemove" ; public static ALL_END : string = "touchend+mousemove" ; public static ALL_CANCEL : string = "touchendoutside+mouseup" ; public static LOADING_ERROR : string = "loadingError" ; public static includeEvent ( eventName ) { for ( let key in EventManager ) { let value = ( < any > EventManager ) [ key ] ; if ( typeof value == "string" && value == eventName ) { return true ; } } return false ; } public static eventIncludes ( name ) { return EventManager . event . listenerCount ( name ) > 0 ; } param name param fn param context public static on ( name , fn , context ? ) { EventManager . event . on ( name , < any > fn , context ) ; } public static once ( name , fn , context ? ) { EventManager . event . once ( name , < any > fn , context ) ; } public static emit ( event , ... args ) { EventManager . event . emit ( event , ... args ) ; } public static off ( name , fn ? , context ? ) { EventManager . event . off ( name , < any > fn , context ) ; } public static offAll ( ) { let names = EventManager . event . eventNames ( ) ; if ( Array . isArray ( names ) ) { names . forEach ( ( name ) => { EventManager . event . removeAllListeners ( name ) ; } ) ; } } }