import 'p2' ; import 'pixi' ; import 'phaser' ; import * as WebFont from 'webfontloader' ; import { Boot , Menu , Gameplay } from './States' ; namespace BoilerPlate { export class Game extends Phaser . Game { constructor ( ) { super ( < Phaser . IGameConfig > { enableDebug : false , width : GAME_WIDTH , height : GAME_HEIGHT , renderer : Phaser . AUTO , parent : 'content' , transparent : true , antialias : true , preserveDrawingBuffer : false , physicsConfig : null , seed : '' , state : null , forceSetTimeOut : false } ) ; this . clearBeforeRender = false ; Phaser . Device . whenReady ( ( ) => { this . stage . disableVisibilityChange = true ; let event = this . device . desktop ? 'click' : 'touchstart' ; document . getElementById ( 'content' ) . addEventListener ( event , ( e ) => { this . gameResumed ( e ) ; } ) ; } ) ; this . state . add ( 'game' , { create : this . stateCreator . bind ( this ) , preload : this . statePreloader . bind ( this ) } , true ) ; } /**
         * Here we load all the Azerion scripts we need
         */ private statePreloader ( ) { libs . forEach ( ( library ) => { this . load . script ( library , library ) ; } ) ; } private stateCreator ( ) { this . plugins . add ( Fabrique . Plugins . GameEvents ) ; this . plugins . add ( Fabrique . Plugins . GoogleAnalytics ) ; this . plugins . add ( Fabrique . Plugins . GameAnalytics ) ; this . plugins . add ( PhaserAds . AdManager ) ; this . plugins . add ( < any > PhaserSuperStorage . StoragePlugin ) ; this . plugins . add ( PhaserCachebuster . CacheBuster ) ; this . plugins . add ( PhaserSpine . SpinePlugin ) ; this . plugins . add ( PhaserI18n . Plugin , { fallbackLng : 'en' , load : 'languageOnly' , backend : { loadPath : 'assets/locales/locale_{{lng}}.json' } } ) ; ( < any > this ) . storage . forcePromises = true ; this . state . add ( Boot . Name , Boot , false ) ; this . state . add ( Fabrique . SplashScreen . Preloader . Name , Fabrique . SplashScreen . Preloader , false ) ; this . state . add ( Menu . Name , Menu , false ) ; this . state . add ( Gameplay . Name , Gameplay , false ) ; let updateText = ( ) : void => { this . recursiveUpdateText ( this . stage ) ; } ; WebFont . load ( < WebFont . Config > { custom : < WebFont . Custom > { families : [ 'Aller Display' ] , urls : [ 'assets/css/AllerDisplay.css' ] } , active : updateText , inactive : updateText } ) ; this . state . start ( Boot . Name ) ; this . state . remove ( 'game' ) ; } param obj public recursiveUpdateText ( obj ) { if ( obj instanceof Phaser . Text ) { ( < any > obj ) . dirty = true ; } if ( obj . children && obj . children . length > 0 ) { obj . children . forEach ( ( child ) => { this . recursiveUpdateText ( child ) ; } ) ; } } } } new BoilerPlate . Game ( ) ;