轉載及補充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);