egret 微信小游戏切入前台监听

转载及补充https://blog.csdn.net/qq_39194398/article/details/80909113#commentBox
第8条 返回前台(游戏激活),在游戏项目中主要UI层加监听
    1.在egret的platform文件declare interface Platform和class DebugPlatform implements Platform 中添加

        declare interface Platform {
            onShow(callback: Function, obj: Any): void;
        }
        class DebugPlatform implements Platform {
            onShow(callback: Function, obj: Any): void { };
        }

    2.微信项目中 platform.js文件的class WxgamePlatform {}里添加
    

        onShow(fun, obj) {
            wx.onShow(function() {
                fun.call(obj);
            })
        } 

   
        
    3. egret 关键位置调用

platform.onShow(this.onshow, this);


 

猜你喜欢

转载自blog.csdn.net/u010243607/article/details/83026154
今日推荐