Commit da3a1f25 authored by asdf's avatar asdf

测试监听后台

parent 33b0bcf2
...@@ -123,13 +123,13 @@ cc.Class({ ...@@ -123,13 +123,13 @@ cc.Class({
} }
}) })
cc.game.on(cc.game.EVENT_HIDE, function () { window.addEventListener('message',(e)=>{
console.log("cc.game.EVENT_HIDE"); console.log('message')
console.log(e)
}); let msgData = e.data;
cc.game.on(cc.game.EVENT_SHOW, function () { if(msgData.action==="course-ready"){
console.log("cc.game.EVENT_HIDE"); this.stopBgm();
}
}); });
}, },
...@@ -202,9 +202,14 @@ cc.Class({ ...@@ -202,9 +202,14 @@ cc.Class({
return; return;
} }
cc.assetManager.loadRemote(this.data.contentObj.bgm_url, null, (err, clip) => { cc.assetManager.loadRemote(this.data.contentObj.bgm_url, null, (err, clip) => {
cc.audioEngine.play(clip, true, 1); this.bgAudioId = cc.audioEngine.play(clip, true, 1);
}); });
}, },
stopBgm(){
if(this.bgAudioId){
cc.audioEngine.stop(this.bgAudioId);
}
},
initData() { initData() {
// 所有全局变量 默认都是null // 所有全局变量 默认都是null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment