class Main extends egret . DisplayObjectContainer { public constructor ( ) { super ( ) ; this . addEventListener ( egret . Event . ADDED_TO_STAGE , this . onAddToStage , this ) ; } private onAddToStage ( event ) { egret . lifecycle . addLifecycleListener ( ( context ) => { context . onUpdate = ( ) => { } ; } ) ; egret . lifecycle . onPause = ( ) => { egret . ticker . pause ( ) ; } ; egret . lifecycle . onResume = ( ) => { egret . ticker . resume ( ) ; } ; this . runGame ( ) . catch ( e => { console . log ( e ) ; } ) ; } private async runGame ( ) { await this . loadResource ( ) ; this . createGameScene ( ) ; const result = await RES . getResAsync ( "description_json" ) ; await platform . login ( ) ; const userInfo = await platform . getUserInfo ( ) ; console . log ( userInfo ) ; } private async loadResource ( ) { try { const loadingView = new LoadingUI ( ) ; this . stage . addChild ( loadingView ) ; await RES . loadConfig ( "resource/default.res.json" , "resource/" ) ; await RES . loadGroup ( "preload" , 1 , loadingView ) ; RES . loadGroup ( "menus" , 0 ) ; this . stage . removeChild ( loadingView ) ; } catch ( e ) { console . error ( e ) ; } } /**
     * 加载用户资料，在这里随机产生
     */ private user : User = PukerUtils . getRandomUser ( ) ; /**
     * 创建游戏场景
     * Create a game scene
     */ private createGameScene ( ) { /** 舞台大小 */ let layout = RES . getRes ( "layout_json" ) . layout ; this . stage . orientation = egret . OrientationMode . LANDSCAPE ; this . stage . setContentSize ( layout . stageWidth , layout . stageHeight ) ; console . log ( "舞台大小：" , this . stage . stageWidth , "*" , this . stage . stageHeight ) ; /** 起始界面 */ let startScene = new StartScene ( this . user ) ; startScene . name = "startScene" ; this . addChild ( startScene ) ; } }