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

Change request

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