[]在微信分享成功的回调函数里,Laya播放音效失败。

在游戏里直接调用pause,然后resume,背景音乐先消失,后出现,
在wx分享成功的回调函数里,调用resume打印显示调用成功,但并未播放音乐。
 
 
wx.shareAppMessage({
title: "小猪佩奇身上纹,掌声送给社会人",
imageUrl: "images/boss.png",
success: function () {
gameex.bar.shareCount += 1;
gameex.bar.clearCountDown();
gameex.snakeSelf.updateState(EN_SNAKE_STATE_NORMAL);
gameex.snakeSelf.setLength(3)
gameex.buffManager.buildBuff(EN_SNAKE_BUFF_ID_1, gameex.snakeSelf, [4000]);
// gameex.snakeSelf.speed = gameex.snakeSelf.speedBak
gameex.resume()
gameex.gameInfo.visible = true;
gameex.bar.destoyRankSprite() 
this.nCountDown = 15;
// console.log(gameex.snakeSelf)
}
})
 
 
//暂停
GameEx.prototype.pause = function () {
console.log("停止播放音乐")
Laya.SoundManager.stopMusic();
//停止游戏主循环
Laya.timer.clear(this, this.onLoop);
//移除舞台的鼠标移动事件
Laya.stage.off(Laya.Event.MOUSE_MOVE);

//恢复
GameEx.prototype.resume = function () {
//在循环中创建敌人
Laya.timer.frameLoop(1,this,this.onLoop);
console.log("恢复播放音乐")
Laya.SoundManager.stopMusic();
Laya.SoundManager.playMusic("res/sound/BGM.mp3", 0, null);

// var test = new EffectFlicker();
// test.startRun();
// test.startRun();
// test.create(); 
// var test = new Q1Buff1(); 
Laya.stage.off(Laya.Event.MOUSE_DOWN);
Laya.stage.off(Laya.Event.MOUSE_MOVE);
Laya.stage.off(Laya.Event.MOUSE_UP)
Laya.stage.off(Laya.Event.MOUSE_OUT); 
// 鼠标按下事件
Laya.stage.on(Laya.Event.MOUSE_DOWN, this.snakeSelf, this.snakeSelf.onMouseDown);
Laya.stage.on(Laya.Event.MOUSE_UP, this.snakeSelf, this.snakeSelf.onMouseUp);
Laya.stage.on(Laya.Event.MOUSE_OUT, this.snakeSelf, this.snakeSelf.moveOut);
}
 
 
已邀请:

Laya_XSN

赞同来自:

小游戏里resume可能不支持,建议通过其他方式控制声音的播放跟停止操作。

要回复问题请先

商务合作
商务合作