康复游戏-鸟妈妈回家
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.6 KiB

4 years ago
// 音频处理类
// function Sound() {
// this.lib = library;
4 years ago
// this.music = {};
// }
// Sound.of = function () {
// const instance = new Sound();
// instance.init();
// return instance;
// };
// Sound.prototype.init = function () {
// createjs.Sound.alternateExtensions = ['mp3'];
// console.log('createjs.Sound: ', createjs.Sound);
// const sounds = [
// { src: 'public/sounds/bgmMusic.mp3', id: 'bgm' },
// { src: 'public/sounds/excitationMusic.mp3', id: 'excitation' },
// { src: 'public/sounds/amazing.mp3', id: 'amazing' },
// { src: 'public/sounds/unbelievable.mp3', id: 'unbelievable' },
// ];
// createjs.Sound.addEventListener('fileload', function (event) {
// console.log('event: ', event);
// this.music[event.id] = createjs.Sound.createInstance(event.id);
// });
// createjs.Sound.registerSounds(sounds, '../../');
// this.playBgm();
// };
4 years ago
// Sound.prototype.playBgm = function () {
// this.music.bgm && this.music.bgm.play({ loop: -1, volume: 0.3 }); // 播放背景音乐
// };
4 years ago
let music = {};
function initSound() {
4 years ago
createjs.Sound.alternateExtensions = ['mp3'];
const sounds = [
{ src: 'public/sounds/bgmMusic.mp3', id: 'bgm' },
{ src: 'public/sounds/excitationMusic.mp3', id: 'excitation' },
{ src: 'public/sounds/amazing.mp3', id: 'amazing' },
{ src: 'public/sounds/unbelievable.mp3', id: 'unbelievable' },
4 years ago
];
createjs.Sound.addEventListener('fileload', function (event) {
music[event.id] = createjs.Sound.createInstance(event.id);
4 years ago
});
createjs.Sound.registerSounds(sounds, '../../');
}