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