Commit 92720411 authored by wildfirecode's avatar wildfirecode

1

parent f017e7e6
let soundOn = true; let soundOn = true;
// let bgChannel: egret.SoundChannel; let bgChannel: egret.SoundChannel;
// let loading = false; let loading = false;
export const getSoundOn = () => { export const getSoundOn = () => {
return soundOn return soundOn
} }
//document.getElementById('bgmusic').duration
export const toggleSound = () => { export const toggleSound = () => {
soundOn = !soundOn; soundOn = !soundOn;
if(soundOn) { if (bgChannel) {
document.getElementById('bgmusic')['play'](); if (!soundOn) {
}else { bgChannel.stop();
document.getElementById('bgmusic')['pause'](); bgChannel = null;
}
} else {
if (soundOn) {
playBg();
}
} }
// if (bgChannel) {
// if (!soundOn) {
// bgChannel.stop();
// bgChannel = null;
// }
// } else {
// if (soundOn) {
// playBg();
// }
// }
} }
// export const playBg = async () => { export const playBg = async () => {
// if (bgChannel) return; if (bgChannel) return;
// if (loading) return; if (loading) return;
// loading = true; loading = true;
// RES.getResByUrl(window['musciURL'], (bg) => { const bg = await RES.getResAsync('bg_mp3');
// bgChannel = bg.play(); bgChannel = bg.play();
// loading = false; loading = false;
// }, this, RES.ResourceItem.TYPE_SOUND); }
// }
export enum SoundType { export enum SoundType {
click = 'click', click = 'click',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment