转载及补充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);