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

fix: bugs

parent d267b5f7
......@@ -34,7 +34,9 @@ export class MyGame extends Game {
imgUrlList.push(this.data.popUpPosition.bgItem.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 => {
audioUrlList.push(data.audio_url);
......@@ -179,25 +181,53 @@ export class MyGame extends Game {
}
eyeOpen = true;
playingTotalAuido = false;
initButton() {
const btn = new TouchSprite();
btn.init(this.images.get('btn_eye_open'));
btn.x = this._parent.canvasWidth - 60 * this.mapScale;
btn.y = this._parent.canvasHeight - 60 * this.mapScale;
btn.setScaleXY(this.mapScale);
btn.addTouchBeganListener(() => {
jelly(btn);
const eyeBtn = new TouchSprite();
eyeBtn.init(this.images.get('btn_eye_open'));
eyeBtn.x = this._parent.canvasWidth - 60 * this.mapScale;
eyeBtn.y = this._parent.canvasHeight - 150 * this.mapScale;
eyeBtn.setScaleXY(this.mapScale);
eyeBtn.addTouchBeganListener(() => {
jelly(eyeBtn);
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.middleBg2, { alpha: 1 }, 0.2);
} 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.middleBg2, { alpha: 0 }, 0.2);
}
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