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

fix: bugs

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