Commit da3a1f25 authored by asdf's avatar asdf

测试监听后台

parent 33b0bcf2
......@@ -123,13 +123,13 @@ cc.Class({
}
})
cc.game.on(cc.game.EVENT_HIDE, function () {
console.log("cc.game.EVENT_HIDE");
});
cc.game.on(cc.game.EVENT_SHOW, function () {
console.log("cc.game.EVENT_HIDE");
window.addEventListener('message',(e)=>{
console.log('message')
console.log(e)
let msgData = e.data;
if(msgData.action==="course-ready"){
this.stopBgm();
}
});
},
......@@ -202,9 +202,14 @@ cc.Class({
return;
}
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() {
// 所有全局变量 默认都是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