Commit bb4c13a8 authored by 范雪寒's avatar 范雪寒

fix: bugs

parent 5e71f774
......@@ -42,7 +42,6 @@
<app-audio-recorder style="float: left; margin-bottom: -15px;" [audioUrl]="item.groupAudio[i]"
(audioUploaded)="onGroupAudioUploadSuccess($event, i)">
</app-audio-recorder>
<div *ngFor="let line of group; let j = index">
<div style="width: 660px; float: left;" class="border">
<div style="float: left;">
......@@ -57,6 +56,16 @@
<app-audio-recorder style="float: left;" [audioUrl]="line.audio"
(audioUploaded)="onLineAudioUploadSuccess($event, i, j)">
</app-audio-recorder>
<br><br>
<span style="float: left; height: 30px; font-size: 18px;">分组音频:</span>
<br><br><br><br><br>
<div *ngFor="let audioData of line.groupAudios; let k = index">
<span style="float: left; height: 30px; font-size: 18px;">{{audioData.text}}:</span>
<app-audio-recorder style="float: left;" [audioUrl]="audioData.audio"
(audioUploaded)="onLineGroupAudioUploadSuccess($event, i, j, k)">
</app-audio-recorder>
<br><br>
</div>
</div>
<span style="float: none;">&nbsp;</span>
<button nz-button class="" style="float: right; color: red;" (click)="removeLine(i, j)">删除</button>
......
......@@ -26,7 +26,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
img: '',
audio: '',
groups: [0],
letterDataList: []
letterDataList: [],
groupAudios: [{
text: '',
audio: ''
}],
});
this.save();
}
......@@ -110,9 +114,15 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
line: false, // 下划线
number: 0, // 下划线下方的数字
group: 0, // 分组
point: false // 重音符号
point: false, // 重音符号
}
});
lineData.groupAudios = [{
text: lineData.word,
audio: ''
}];
this.save();
}
......@@ -188,6 +198,22 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
this.item.group[groupIdx][lineIdx].groups = new Array(maxGroup + 1).fill('0');
this.item.group[groupIdx][lineIdx].groupAudios = [];
console.log('maxGroup = ' + maxGroup);
for (let i = 0; i < maxGroup + 1; i++) {
this.item.group[groupIdx][lineIdx].groupAudios.push({
text: letterDataList
.filter(data => {
return data.group == i;
})
.map(data => {
return data.letter;
})
.join(''),
audio: ''
});
}
this.save();
}
......@@ -220,6 +246,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.save();
}
onLineGroupAudioUploadSuccess(e, groupIdx, lineIdx, k) {
this.item.group[groupIdx][lineIdx].groupAudios[k].audio = e.url;
this.save();
}
/**
* 储存音频数据
* @param e
......
......@@ -71,6 +71,7 @@ export class Game {
}
}
// console.log('playAuido:' + key);
this._currentPlayingAudioName = key;
this._currentPlayingAudioCallback = callback;
this._parent.playAudio(key, now, () => {
......
......@@ -311,7 +311,7 @@ export class MyGame extends Game {
popUpBg.alpha = 0;
popUpBg.childDepandAlpha = true;
popUpBg.addTouchBeganListener(() => {
});
this.addChild(popUpBg);
......@@ -333,6 +333,7 @@ export class MyGame extends Game {
btnClose.addTouchBeganListener(() => {
jelly(btnClose);
this.hidePopUp();
this.playAudio('pop_up');
});
popUpWinBg.addChild(btnClose);
......@@ -345,15 +346,23 @@ export class MyGame extends Game {
wordMiddle.setName('wordMiddle');
popUpWinBg.addChild(wordMiddle);
wordMiddle.addTouchBeganListener(()=>{
this.playAudio(this.popUpData.audio);
});
const changeBtn = new TouchSprite();
changeBtn.init(this.images.get('btn_switch'));
changeBtn.x = (popUpWinBg.width / 2 - 100);
changeBtn.y = (popUpWinBg.height / 2 - 100);
changeBtn.visible = false;
changeBtn.setName('changeBtn');
changeBtn.addTouchBeganListener(async () => {
jelly(changeBtn);
tweenChange(changeBtn, { alpha: 0 }, 0.2, ()=>{
changeBtn.visible = false;
changeBtn.alpha = 1;
});
await this.changePopUp();
changeBtn.visible = false;
});
popUpWinBg.addChild(changeBtn);
}
......@@ -362,9 +371,7 @@ export class MyGame extends Game {
popUp(popUpData) {
this.popUpData = popUpData;
const popUpBg = this.getChildByName('popUpBg');
tweenChange(popUpBg, { alpha: 1 }, 0.2);
const popUpWinBg = this.getChildByName('popUpWinBg');
tweenChange(popUpWinBg, { alpha: 1 }, 0.2);
const wordMiddle = this.seekChildByName('wordMiddle');
wordMiddle.text = popUpData.word;
......@@ -372,6 +379,8 @@ export class MyGame extends Game {
wordMiddle.x = 0;
wordMiddle.y = -150;
this.playAudio('pop_up');
const nodePosBaseOld = popUpWinBg.seekChildByName('nodePosBase');
if (nodePosBaseOld) {
popUpWinBg.removeChild(nodePosBaseOld);
......@@ -382,6 +391,11 @@ export class MyGame extends Game {
nodePosBase.childDepandAlpha = true;
popUpWinBg.addChild(nodePosBase);
const groupNumber = Math.max(...popUpData.letterDataList.map(letterData => letterData.group)) + 1;
const groupShowedList = new Array(groupNumber).fill(false);
let labelGroupList = [];
let blankWidth = 0;
let width = 0;
popUpData.letterDataList.forEach((letterData, idx) => {
......@@ -396,8 +410,31 @@ export class MyGame extends Game {
wordMiddle.anchorY = 0.5;
wordMiddle.x = width + letterData.group * 20;
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);
}
groupShowedList[letterData.group] = true;
if (groupShowedList.every(show => show == true)) {
const changeBtn = this.seekChildByName('changeBtn');
changeBtn.visible = true;
tweenChange(changeBtn, { alpha: 1 }, 0.2);
}
this.playAudio(popUpData.groupAudios[letterData.group].audio);
});
nodePosBase.addChild(wordMiddle);
if (!labelGroupList[letterData.group]) {
labelGroupList.push([]);
}
labelGroupList[letterData.group].push(wordMiddle);
blankWidth = letterData.group * 20;
width += wordMiddle.width;
......@@ -412,10 +449,20 @@ export class MyGame extends Game {
line.setName(`line_${idx}`);
nodePosBase.addChild(line);
});
const changeBtn = this.seekChildByName('changeBtn');
changeBtn.visible = true;
changeBtn.visible = false;
changeBtn.alpha = 0;
nodePosBase.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}`);
wordMiddle.visible = true;
wordMiddle.alpha = 0.00000001;
});
});
}
hidePopUp() {
......@@ -427,7 +474,7 @@ export class MyGame extends Game {
async changePopUp() {
const nodePosBaseOld = this.seekChildByName('nodePosBase');
await asyncTweenChange(nodePosBaseOld, { alpha: 0 }, 0.2);
await asyncTweenChange(nodePosBaseOld, { alpha: 0 }, 0.3);
const popUpWinBg = this.getChildByName('popUpWinBg');
const nodePosBaseOld2 = popUpWinBg.seekChildByName('nodePosBase');
......@@ -440,6 +487,7 @@ export class MyGame extends Game {
nodePosBase.childDepandAlpha = true;
popUpWinBg.addChild(nodePosBase);
let labelGroupList = [];
let blankWidth = 0;
let width = 0;
this.popUpData.letterDataList.forEach((letterData, idx) => {
......@@ -456,7 +504,32 @@ export class MyGame extends Game {
wordMiddle.x = width + letterData.group * 20;
wordMiddle.y = 120;
nodePosBase.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 groupShowedList = new Array(groupNumber).fill(false);
wordMiddle.addTouchBeganListener(()=>{
// changeBtn
console.log('汪汪汪');
for (const label of labelGroupList[letterData.group]) {
label.visible = true;
tweenChange(label, { alpha: 1 }, 0.2);
}
groupShowedList[letterData.group] = true;
if (groupShowedList.every(show => show == true)) {
const changeBtn = this.seekChildByName('changeBtn');
changeBtn.visible = true;
tweenChange(changeBtn, { alpha: 1 }, 0.2);
}
this.playAudio(this.popUpData.groupAudios[letterData.group].audio);
});
if (!labelGroupList[letterData.group]) {
labelGroupList.push([]);
}
labelGroupList[letterData.group].push(wordMiddle);
blankWidth = letterData.group * 20;
......@@ -482,5 +555,8 @@ export class MyGame extends Game {
});
nodePosBase.x = -(width + blankWidth) / 2;
nodePosBase.alpha = 0;
await asyncTweenChange(nodePosBase, { alpha: 1 }, 0.3);
}
}
......@@ -19,6 +19,8 @@ const res = [
const resAudio = [
// ['click', "assets/play/music/click.mp3"],
['pop_up', "assets/play/music/pop_up.mp3"],
];
export { res, resAudio };
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