Commit 7d564af6 authored by 李维's avatar 李维

Change request

based on UAT feedback
parent 54716c2c
......@@ -119,6 +119,9 @@ export class PlayComponent implements OnInit, OnDestroy {
underLine = [];
wordAll = [];
currentClickNode = null;
setWordLoad(id: string, letterId:string, loaded:boolean, letter: Label):void{
if(!this.wordLoad[id]){
......@@ -865,7 +868,9 @@ export class PlayComponent implements OnInit, OnDestroy {
scale = 0.8
}
let allUnderLines = []
let allUnderLines = [];
let allWordsLines = [];
for(let i = 0; i < len; ++ i) {
//字母
let letter = word_content.letters[i];
......@@ -905,6 +910,7 @@ export class PlayComponent implements OnInit, OnDestroy {
word_bg.addChild(lts_);
allUnderLines.push(lts_)
}
allWordsLines.push(letter_spr);
height = letter_spr.height;
if(index === 0){
......@@ -916,7 +922,8 @@ export class PlayComponent implements OnInit, OnDestroy {
}
this.underLine.push(allUnderLines);
this.wordAll.push(allWordsLines);
word_bg.setSize(totalWidth, height * 2);
word_bg_group.addChild(word_bg);
......@@ -945,14 +952,45 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
rePosition(index) {
let words = this.wordAll[index];
let totalWidth = 0;
let word_content = this.saveData.wordArr[index];
let len = word_content.letters.length
let scale = 1
if(len>=13 && len<18) {
scale = 0.9
} else if(len>=18 && len<20) {
scale = 0.85
} else if(len>=20) {
scale = 0.8
}
words.forEach(element => {
element.refreshSize();
let ltBounds = element.getBoundingBox();
element.x = ltBounds.width * scale / 2 + totalWidth * scale + 5;
totalWidth += ltBounds.width;
});
}
creatOptions(index, parent, leftText, rightText, correctOption) {
let baseX = parent.width - 99 * 2
let bgLeftHighlight = new ShapeRoundRect()
bgLeftHighlight.x = baseX;
bgLeftHighlight.y = 0;
bgLeftHighlight.fillColor = "#EC6101" // `#${this.saveData.optionColor_left?this.saveData.optionColor_left:"FFFFFF"}`;
bgLeftHighlight.setSize(99, 57, 0);
bgLeftHighlight.alpha = 0;
let bgLeft = new ShapeRoundRect()
bgLeft.x = baseX;
bgLeft.y = 0;
bgLeft.fillColor = "#a1b4c1" // `#${this.saveData.optionColor_left?this.saveData.optionColor_left:"FFFFFF"}`;
bgLeft.setSize(99, 57, 0);
bgLeft["index"] = index
bgLeft["index"] = index;
bgLeft["highlight"] = bgLeftHighlight;
bgLeft["correct"] = correctOption=="left"?true:false;
let textLeft = new Label();
......@@ -964,14 +1002,24 @@ export class PlayComponent implements OnInit, OnDestroy {
textLeft.x = 99 / 2;
textLeft.y = 57 / 2;
bgLeft.addChild(textLeft);
bgLeftHighlight.addChild(textLeft);
parent.addChild(bgLeft);
parent.addChild(bgLeftHighlight);
let bgRightHighlight = new ShapeRoundRect()
bgRightHighlight.x = baseX + 99;
bgRightHighlight.y = 0;
bgRightHighlight.fillColor = "#EC6101" // `#${this.saveData.optionColor_left?this.saveData.optionColor_left:"FFFFFF"}`;
bgRightHighlight.setSize(99, 57, 0)
bgRightHighlight.alpha = 0;
let bgRight = new ShapeRoundRect()
bgRight.x = baseX + 99;
bgRight.y = 0;
bgRight.fillColor = "#93a7b7" // `#${this.saveData.optionColor_right?this.saveData.optionColor_right:"FFFFFF"}`;
bgRight.setSize(99, 57, 0)
bgRight["index"] = index
bgRight["index"] = index;
bgRight["highlight"] = bgRightHighlight;
bgRight["correct"] = correctOption=="left"?false:true;
let textRight = new Label();
......@@ -983,7 +1031,9 @@ export class PlayComponent implements OnInit, OnDestroy {
textRight.x = 99 / 2;
textRight.y = 57 / 2;
bgRight.addChild(textRight);
bgRightHighlight.addChild(textRight);
parent.addChild(bgRight);
parent.addChild(bgRightHighlight);
this.optionsAll.push(bgLeft)
this.optionsAll.push(bgRight)
......@@ -1043,7 +1093,6 @@ export class PlayComponent implements OnInit, OnDestroy {
mapDown(event) {
if (!this.canTouch) {
return;
}
......@@ -1071,24 +1120,15 @@ export class PlayComponent implements OnInit, OnDestroy {
for(let i = 0; i < this.optionsAll.length; ++ i) {
let option = this.optionsAll[i];
if (this.checkClickTarget(option)) {
this.currentClickNode = option["highlight"]
option["highlight"].alpha = 1;
console.log(option["highlight"])
if(option["correct"]) {
if(this.opend[option["index"]]) {
// console.log(this.underLine[option["index"]])
} else {
this.opend[option["index"]] = true;
}
// this.playAudio("sm-choice-correct", false, ()=>{
// if(this.saveData.indexAudio[option["index"]]) {
// this.playAudio(this.saveData.indexAudio[option["index"]], true, ()=>{
// this.canTouch = true;
// })
// } else {
// this.canTouch = true;
// }
// })
let word = this.word_arr_left[option["index"]];
let letters:Array<Label> = word.children.slice(1);
for (let j=0; j<letters.length;j++) {
......@@ -1099,16 +1139,8 @@ export class PlayComponent implements OnInit, OnDestroy {
}
word.wordLoaded = true;
this.stopAllAudio()
this.playAudio("sm-choice-correct", false, ()=>{
// this.stopAllAudio()
// this.playAudio(this.saveData.wordArr[option["index"]].word_audio_url);
})
} else {
this.playAudio("sm-choice-correct")
}
}
}
......@@ -1181,6 +1213,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.underLine[i].forEach(element => {
element.alpha = 0;
});
this.rePosition(i)
this.stopAllAudio()
this.playAudio(this.saveData.wordArr[i].word_audio_url);
}
......@@ -1252,7 +1285,12 @@ export class PlayComponent implements OnInit, OnDestroy {
}
mapUp(event) {
if( this.currentClickNode) {
setTimeout(() => {
this.currentClickNode.alpha = 0;
this.currentClickNode = null
}, 500);
}
}
......
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