|
|
@ -18,7 +18,10 @@ Sound.of = (function () { |
|
|
|
|
|
|
|
Sound.prototype.init = function () { |
|
|
|
createjs.Sound.alternateExtensions = ['mp3']; |
|
|
|
const sounds = [{ src: 'sounds/bgmMusic.mp3', id: 'bgm' }]; |
|
|
|
const sounds = [ |
|
|
|
{ src: 'sounds/bgmMusic.mp3', id: 'bgm' }, |
|
|
|
{ src: 'sounds/audio1.mp3', id: 'audio1' }, |
|
|
|
]; |
|
|
|
const _this = this; |
|
|
|
createjs.Sound.addEventListener('fileload', function (event) { |
|
|
|
_this.music[event.id] = createjs.Sound.createInstance(event.id); |
|
|
@ -31,6 +34,12 @@ Sound.prototype.playBgm = function () { |
|
|
|
this.music.bgm && this.music.bgm.play({ loop: -1, volume: 0.3 }); // 播放背景音乐
|
|
|
|
}; |
|
|
|
|
|
|
|
Sound.prototype.playBomb = function (direction) { |
|
|
|
if (direction === 0 || direction === 1) { |
|
|
|
this.music.audio1 && this.music.audio1.play(); // 播放爆炸声
|
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// let music = {};
|
|
|
|
// function initSound() {
|
|
|
|
// createjs.Sound.alternateExtensions = ['mp3'];
|
|
|
|