Commit 10f7be4b authored by 范雪寒's avatar 范雪寒

fix: bugs

parent d267b5f7
...@@ -34,7 +34,9 @@ export class MyGame extends Game { ...@@ -34,7 +34,9 @@ export class MyGame extends Game {
imgUrlList.push(this.data.popUpPosition.bgItem.url); imgUrlList.push(this.data.popUpPosition.bgItem.url);
imgUrlList.push(this.data.popUpPosition.bgItem2.url); imgUrlList.push(this.data.popUpPosition.bgItem2.url);
// audioUrlList.push(this.data.titleLetterAudio); audioUrlList.push(this.data.titleAudio);
audioUrlList.push(this.data.titleLetterAudio);
audioUrlList.push(this.data.totalAudio);
this.data.popUpPosition.hotZoneItemArr.forEach(data => { this.data.popUpPosition.hotZoneItemArr.forEach(data => {
audioUrlList.push(data.audio_url); audioUrlList.push(data.audio_url);
...@@ -179,25 +181,53 @@ export class MyGame extends Game { ...@@ -179,25 +181,53 @@ export class MyGame extends Game {
} }
eyeOpen = true; eyeOpen = true;
playingTotalAuido = false;
initButton() { initButton() {
const btn = new TouchSprite(); const eyeBtn = new TouchSprite();
btn.init(this.images.get('btn_eye_open')); eyeBtn.init(this.images.get('btn_eye_open'));
btn.x = this._parent.canvasWidth - 60 * this.mapScale; eyeBtn.x = this._parent.canvasWidth - 60 * this.mapScale;
btn.y = this._parent.canvasHeight - 60 * this.mapScale; eyeBtn.y = this._parent.canvasHeight - 150 * this.mapScale;
btn.setScaleXY(this.mapScale); eyeBtn.setScaleXY(this.mapScale);
btn.addTouchBeganListener(() => { eyeBtn.addTouchBeganListener(() => {
jelly(btn); jelly(eyeBtn);
if (this.eyeOpen) { if (this.eyeOpen) {
btn.init(this.images.get('btn_eye_close')); eyeBtn.init(this.images.get('btn_eye_close'));
tweenChange(this.middleBg1, { alpha: 0 }, 0.2); tweenChange(this.middleBg1, { alpha: 0 }, 0.2);
tweenChange(this.middleBg2, { alpha: 1 }, 0.2); tweenChange(this.middleBg2, { alpha: 1 }, 0.2);
} else { } else {
btn.init(this.images.get('btn_eye_open')); eyeBtn.init(this.images.get('btn_eye_open'));
tweenChange(this.middleBg1, { alpha: 1 }, 0.2); tweenChange(this.middleBg1, { alpha: 1 }, 0.2);
tweenChange(this.middleBg2, { alpha: 0 }, 0.2); tweenChange(this.middleBg2, { alpha: 0 }, 0.2);
} }
this.eyeOpen = !this.eyeOpen; this.eyeOpen = !this.eyeOpen;
}); });
this.addChild(btn); this.addChild(eyeBtn);
const btnPlay = new TouchSprite();
btnPlay.init(this.images.get('btn_play'));
btnPlay.x = this._parent.canvasWidth - 60 * this.mapScale;
btnPlay.y = this._parent.canvasHeight - 60 * this.mapScale;
btnPlay.setScaleXY(this.mapScale);
btnPlay.addTouchBeganListener(() => {
jelly(btnPlay);
if (this.data.totalAudio != '') {
if (!this.playingTotalAuido) {
this.playingTotalAuido = true;
this.playAudio(this.data.totalAudio, true, () => {
this.playingTotalAuido = false;
btnPlay.init(this.images.get('btn_play'));
});
btnPlay.init(this.images.get('btn_pause'));
} else {
this.playingTotalAuido = false;
btnPlay.init(this.images.get('btn_play'));
const audio = this._parent.audioObj[this.data.totalAudio];
if (audio && !audio.paused) {
audio.pause();
}
}
}
});
this.addChild(btnPlay);
} }
} }
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