Commit 256a8bcf authored by 范雪寒's avatar 范雪寒

fix: bugs

parent c7c8bfe2
...@@ -36,8 +36,12 @@ export class MyGame extends Game { ...@@ -36,8 +36,12 @@ export class MyGame extends Game {
group.forEach(line => { group.forEach(line => {
imgUrlList.push(line.img); imgUrlList.push(line.img);
audioUrlList.push(line.audio); audioUrlList.push(line.audio);
audioUrlList.push(...line.groupAudios.map(data => data.audio));
}); });
}); });
audioUrlList.push(...this.data.groupAudio);
imgUrlList.push(this.data.middleImg); imgUrlList.push(this.data.middleImg);
audioUrlList.push(this.data.titleLetterAudio); audioUrlList.push(this.data.titleLetterAudio);
audioUrlList.push(this.data.titleAudio); audioUrlList.push(this.data.titleAudio);
...@@ -266,8 +270,6 @@ export class MyGame extends Game { ...@@ -266,8 +270,6 @@ export class MyGame extends Game {
} }
}); });
console.log('numberDataList = ' + numberDataList);
numberDataList.forEach(numberData => { numberDataList.forEach(numberData => {
const letterLabel = new MyLabel(); const letterLabel = new MyLabel();
letterLabel.fontSize = 20; letterLabel.fontSize = 20;
...@@ -346,7 +348,8 @@ export class MyGame extends Game { ...@@ -346,7 +348,8 @@ export class MyGame extends Game {
wordMiddle.setName('wordMiddle'); wordMiddle.setName('wordMiddle');
popUpWinBg.addChild(wordMiddle); popUpWinBg.addChild(wordMiddle);
wordMiddle.addTouchBeganListener(()=>{ wordMiddle.addTouchBeganListener(() => {
console.log('汪汪汪')
this.playAudio(this.popUpData.audio); this.playAudio(this.popUpData.audio);
}); });
...@@ -358,10 +361,11 @@ export class MyGame extends Game { ...@@ -358,10 +361,11 @@ export class MyGame extends Game {
changeBtn.setName('changeBtn'); changeBtn.setName('changeBtn');
changeBtn.addTouchBeganListener(async () => { changeBtn.addTouchBeganListener(async () => {
jelly(changeBtn); jelly(changeBtn);
tweenChange(changeBtn, { alpha: 0 }, 0.2, ()=>{ tweenChange(changeBtn, { alpha: 0 }, 0.2, () => {
changeBtn.visible = false; changeBtn.visible = false;
changeBtn.alpha = 1; changeBtn.alpha = 1;
}); });
this.playAudio('click_green_btn');
await this.changePopUp(); await this.changePopUp();
}); });
popUpWinBg.addChild(changeBtn); popUpWinBg.addChild(changeBtn);
...@@ -391,11 +395,21 @@ export class MyGame extends Game { ...@@ -391,11 +395,21 @@ export class MyGame extends Game {
nodePosBase.childDepandAlpha = true; nodePosBase.childDepandAlpha = true;
popUpWinBg.addChild(nodePosBase); popUpWinBg.addChild(nodePosBase);
const wordBase = new TouchSprite();
wordBase.childDepandAlpha = true;
wordBase.setName('wordBase');
nodePosBase.addChild(wordBase);
const lineBase = new TouchSprite();
lineBase.childDepandAlpha = true;
lineBase.setName('lineBase');
nodePosBase.addChild(lineBase);
const groupNumber = Math.max(...popUpData.letterDataList.map(letterData => letterData.group)) + 1; const groupNumber = Math.max(...popUpData.letterDataList.map(letterData => letterData.group)) + 1;
const groupShowedList = new Array(groupNumber).fill(false); const groupShowedList = new Array(groupNumber).fill(false);
let labelGroupList = []; const labelGroupList = [];
let blankWidth = 0; let blankWidth = 0;
let width = 0; let width = 0;
popUpData.letterDataList.forEach((letterData, idx) => { popUpData.letterDataList.forEach((letterData, idx) => {
...@@ -412,8 +426,6 @@ export class MyGame extends Game { ...@@ -412,8 +426,6 @@ export class MyGame extends Game {
wordMiddle.y = 120; wordMiddle.y = 120;
wordMiddle.visible = false; wordMiddle.visible = false;
wordMiddle.addTouchBeganListener(() => { wordMiddle.addTouchBeganListener(() => {
// changeBtn
console.log('汪汪汪');
for (const label of labelGroupList[letterData.group]) { for (const label of labelGroupList[letterData.group]) {
label.visible = true; label.visible = true;
tweenChange(label, { alpha: 1 }, 0.2); tweenChange(label, { alpha: 1 }, 0.2);
...@@ -425,10 +437,11 @@ export class MyGame extends Game { ...@@ -425,10 +437,11 @@ export class MyGame extends Game {
tweenChange(changeBtn, { alpha: 1 }, 0.2); tweenChange(changeBtn, { alpha: 1 }, 0.2);
} }
this.playAudio(popUpData.groupAudios[letterData.group].audio); this.playAudio('click_line', true, () => {
this.playAudio(popUpData.groupAudios[letterData.group].audio);
});
}); });
nodePosBase.addChild(wordMiddle); wordBase.addChild(wordMiddle);
if (!labelGroupList[letterData.group]) { if (!labelGroupList[letterData.group]) {
labelGroupList.push([]); labelGroupList.push([]);
...@@ -447,18 +460,19 @@ export class MyGame extends Game { ...@@ -447,18 +460,19 @@ export class MyGame extends Game {
line.y = 170; line.y = 170;
line.scaleX = wordMiddle.width / line.width; line.scaleX = wordMiddle.width / line.width;
line.setName(`line_${idx}`); line.setName(`line_${idx}`);
nodePosBase.addChild(line); lineBase.addChild(line);
}); });
const changeBtn = this.seekChildByName('changeBtn'); const changeBtn = this.seekChildByName('changeBtn');
changeBtn.visible = false; changeBtn.visible = false;
changeBtn.alpha = 0; changeBtn.alpha = 0;
nodePosBase.x = -(width + blankWidth) / 2; lineBase.x = -(width + blankWidth) / 2;
wordBase.x = -(width + blankWidth) / 2;
tweenChange(popUpBg, { alpha: 1 }, 0.2); tweenChange(popUpBg, { alpha: 1 }, 0.2);
tweenChange(popUpWinBg, { alpha: 1 }, 0.2, () => { tweenChange(popUpWinBg, { alpha: 1 }, 0.2, () => {
popUpData.letterDataList.forEach((_, idx) => { popUpData.letterDataList.forEach((_, idx) => {
const wordMiddle = nodePosBase.getChildByName(`wordMiddle_${idx}`); const wordMiddle = wordBase.getChildByName(`wordMiddle_${idx}`);
wordMiddle.visible = true; wordMiddle.visible = true;
wordMiddle.alpha = 0.00000001; wordMiddle.alpha = 0.00000001;
}); });
...@@ -473,19 +487,21 @@ export class MyGame extends Game { ...@@ -473,19 +487,21 @@ export class MyGame extends Game {
} }
async changePopUp() { async changePopUp() {
const nodePosBaseOld = this.seekChildByName('nodePosBase'); const wordBaseOld = this.seekChildByName('wordBase');
await asyncTweenChange(nodePosBaseOld, { alpha: 0 }, 0.3); await asyncTweenChange(wordBaseOld, { alpha: 0 }, 0.3);
const popUpWinBg = this.getChildByName('popUpWinBg'); const popUpWinBg = this.getChildByName('popUpWinBg');
const nodePosBaseOld2 = popUpWinBg.seekChildByName('nodePosBase'); const wordBaseOld2 = popUpWinBg.seekChildByName('wordBase');
if (nodePosBaseOld2) { if (wordBaseOld2) {
popUpWinBg.removeChild(nodePosBaseOld2); popUpWinBg.removeChild(wordBaseOld2);
} }
const nodePosBase = new TouchSprite(); const nodePosBase = this.seekChildByName('nodePosBase');
nodePosBase.setName('nodePosBase');
nodePosBase.childDepandAlpha = true; const wordBase = new TouchSprite();
popUpWinBg.addChild(nodePosBase); wordBase.setName('wordBase');
wordBase.childDepandAlpha = true;
nodePosBase.addChild(wordBase);
let labelGroupList = []; let labelGroupList = [];
let blankWidth = 0; let blankWidth = 0;
...@@ -503,13 +519,13 @@ export class MyGame extends Game { ...@@ -503,13 +519,13 @@ export class MyGame extends Game {
wordMiddle.alpha = 0; wordMiddle.alpha = 0;
wordMiddle.x = width + letterData.group * 20; wordMiddle.x = width + letterData.group * 20;
wordMiddle.y = 120; wordMiddle.y = 120;
nodePosBase.addChild(wordMiddle); wordBase.addChild(wordMiddle);
// tweenChange(wordMiddle, { alpha: 1 }, 0.2); // tweenChange(wordMiddle, { alpha: 1 }, 0.2);
const groupNumber = Math.max(...this.popUpData.letterDataList.map(letterData => letterData.group)) + 1; const groupNumber = Math.max(...this.popUpData.letterDataList.map(letterData => letterData.group)) + 1;
const groupShowedList = new Array(groupNumber).fill(false); const groupShowedList = new Array(groupNumber).fill(false);
wordMiddle.addTouchBeganListener(()=>{ wordMiddle.addTouchBeganListener(() => {
// changeBtn // changeBtn
console.log('汪汪汪'); console.log('汪汪汪');
for (const label of labelGroupList[letterData.group]) { for (const label of labelGroupList[letterData.group]) {
...@@ -535,28 +551,28 @@ export class MyGame extends Game { ...@@ -535,28 +551,28 @@ export class MyGame extends Game {
width += wordMiddle.width; width += wordMiddle.width;
const line = new TouchSprite(); // const line = new TouchSprite();
line.init(this.images.get('img_line_purple')); // line.init(this.images.get('img_line_purple'));
line.anchorX = 0; // line.anchorX = 0;
line.anchorY = 0.5; // line.anchorY = 0.5;
line.x = wordMiddle.x; // line.x = wordMiddle.x;
line.y = 170; // line.y = 170;
line.scaleX = wordMiddle.width / line.width; // line.scaleX = wordMiddle.width / line.width;
line.setName(`line_${idx}`); // line.setName(`line_${idx}`);
nodePosBase.addChild(line); // nodePosBase.addChild(line);
if (letterData.point) { if (letterData.point) {
const point = new TouchSprite(); const point = new TouchSprite();
point.init(this.images.get('Img_point')); point.init(this.images.get('Img_point'));
point.x = wordMiddle.x + 10; point.x = wordMiddle.x + 10;
point.y = wordMiddle.y - 50; point.y = wordMiddle.y - 50;
nodePosBase.addChild(point); wordBase.addChild(point);
} }
}); });
nodePosBase.x = -(width + blankWidth) / 2; wordBase.x = -(width + blankWidth) / 2;
nodePosBase.alpha = 0; wordBase.alpha = 0;
await asyncTweenChange(nodePosBase, { alpha: 1 }, 0.3); await asyncTweenChange(wordBase, { alpha: 1 }, 0.3);
} }
} }
\ No newline at end of file
...@@ -18,8 +18,9 @@ const res = [ ...@@ -18,8 +18,9 @@ const res = [
]; ];
const resAudio = [ const resAudio = [
// ['click', "assets/play/music/click.mp3"],
['pop_up', "assets/play/music/pop_up.mp3"], ['pop_up', "assets/play/music/pop_up.mp3"],
['click_green_btn', "assets/play/music/click_green_btn.mp3"],
['click_line', "assets/play/music/click_line.mp3"],
]; ];
......
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