|
@@ -79,14 +79,22 @@ cc.Class({
|
|
|
|
|
|
let bgmState = cc.sys.localStorage.getItem("game_bgm_state");
|
|
|
if (bgmState!= undefined) {
|
|
|
- this.bgmOpen = bgmState;
|
|
|
+ if (typeof bgmState == "string" && bgmState == "") {
|
|
|
+ this.bgmOpen = true;
|
|
|
+ } else {
|
|
|
+ this.bgmOpen = bgmState;
|
|
|
+ }
|
|
|
} else {
|
|
|
this.bgmOpen = true;
|
|
|
}
|
|
|
|
|
|
let soundEffectState = cc.sys.localStorage.getItem("game_sound_effect_state");
|
|
|
if (soundEffectState!= undefined) {
|
|
|
- this.soundEffectOpen = soundEffectState;
|
|
|
+ if (typeof soundEffectState == "string" && soundEffectState == "") {
|
|
|
+ this.soundEffectOpen = true;
|
|
|
+ } else {
|
|
|
+ this.soundEffectOpen = soundEffectState;
|
|
|
+ }
|
|
|
} else {
|
|
|
this.soundEffectOpen = true;
|
|
|
}
|
|
@@ -105,7 +113,9 @@ cc.Class({
|
|
|
* 播放背景音乐
|
|
|
*/
|
|
|
playBgm () {
|
|
|
- cc.audioEngine.stop(this.currentAudio['bgm']);
|
|
|
+ if (this.currentAudio.hasOwnProperty('bgm')) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (!this.bgmOpen) { return }
|
|
|
this.currentAudio['bgm'] = cc.audioEngine.play(this.bgm, true, this.volume);
|
|
|
},
|
|
@@ -122,6 +132,7 @@ cc.Class({
|
|
|
*/
|
|
|
stopBgm () {
|
|
|
cc.audioEngine.stop(this.currentAudio['bgm']);
|
|
|
+ delete this.currentAudio['bgm'];
|
|
|
},
|
|
|
|
|
|
/**
|