Browse Source

控制结束时暂停脚步声

master
song 4 years ago
parent
commit
6c6eeb37d3
  1. 11
      src/classes/sound.js
  2. 3
      src/custom.js

11
src/classes/sound.js

@ -36,22 +36,21 @@ Sound.prototype.playBgm = function () {
}; };
Sound.prototype.playFootsteps = function () { Sound.prototype.playFootsteps = function () {
console.log('播放脚步声: ', this.music.audio2);
this.music.audio2 && this.music.audio2.play({ loop: -1 }); // 播放脚步声 this.music.audio2 && this.music.audio2.play({ loop: -1 }); // 播放脚步声
}; };
Sound.prototype.pauseFootsteps = function () { Sound.prototype.pauseFootsteps = function () {
this.music.audio2 && this.music.audio2.pause(); // 停止脚步声 this.music.audio2 && this.music.audio2.stop(); // 停止脚步声
console.log('停止脚步声: ', this.music.audio2); console.log('停止脚步声: ');
}; };
Sound.prototype.playBomb = function (direction) { Sound.prototype.playBomb = function (direction) {
if (direction === 0 || direction === 1) { if (direction === 0 || direction === 1) {
this.music.audio1 && this.music.audio1.play(); // 播放跨栏声 this.music.audio1 && this.music.audio1.play(); // 播放跨栏声
this.music.audio2.paused = true; this.pauseFootsteps();
} }
const _this = this; const _this = this;
setTimeout(function () { setTimeout(function () {
_this.music.audio2.paused = false; _this.playFootsteps();
}, 2000); }, 1000);
}; };

3
src/custom.js

@ -48,10 +48,9 @@ function initStage(lib) {
// 游戏结束 显示结束得分面板 // 游戏结束 显示结束得分面板
function gameOver() { function gameOver() {
state = 2; state = 2;
window.soundInstance.pauseFootsteps();
window.soundInstance = Sound.of();
const times = main.times; const times = main.times;
setTimeout(() => { setTimeout(() => {
window.soundInstance.pauseFootsteps();
End.of(config.currentScore || 0); End.of(config.currentScore || 0);
if (config.mode === 0) { if (config.mode === 0) {
finishMessage(config.currentScore, times); finishMessage(config.currentScore, times);

Loading…
Cancel
Save