Commit a39e3835 authored by Chen Jiping's avatar Chen Jiping

fix:调整动画显示方式

parent 23b72a83
...@@ -62,6 +62,7 @@ export class Exercises { ...@@ -62,6 +62,7 @@ export class Exercises {
this.initIndex(); this.initIndex();
this.initCard(); this.initCard();
} }
initBg() { initBg() {
...@@ -244,9 +245,9 @@ export class Exercises { ...@@ -244,9 +245,9 @@ export class Exercises {
return answer; return answer;
} }
getTextView2(letterArr){ getTextView2(letterArr) {
let getLabel =(letter, fontColor)=>{ let getLabel = (letter, fontColor) => {
const label = new Label(); const label = new Label();
label.text = letter; label.text = letter;
...@@ -268,11 +269,13 @@ export class Exercises { ...@@ -268,11 +269,13 @@ export class Exercises {
let x = 0; let x = 0;
let tmpArr = [];
for (let i = 0; i < letterArr.length; ++i) { for (let i = 0; i < letterArr.length; ++i) {
let letter = letterArr[i]; let letter = letterArr[i];
if(!letter){ if (!letter) {
continue; continue;
} }
...@@ -283,16 +286,20 @@ export class Exercises { ...@@ -283,16 +286,20 @@ export class Exercises {
} }
for(let j = 0; j < letter.val.length; ++ j){ for (let j = 0; j < letter.val.length; ++j) {
let label = getLabel(letter.val.charAt(j), fontColor); let label = getLabel(letter.val.charAt(j), fontColor);
label.x = x;
x += label.getBoundingBox().width;
h = label.getBoundingBox().height;
w += label.getBoundingBox().width;
bg.addChild(label); bg.addChild(label);
tmpArr.push(label);
}
} }
for (let i = 0; i < tmpArr.length; ++i) {
let label = tmpArr[i];
label.x = x;
let tW = Math.ceil(label.getBoundingBox().width);
x += tW;
h = label.getBoundingBox().height;
w += tW;
} }
bg.alpha = 0; bg.alpha = 0;
...@@ -334,11 +341,18 @@ export class Exercises { ...@@ -334,11 +341,18 @@ export class Exercises {
let text = this.getTextView2(answerData.letterArr); let text = this.getTextView2(answerData.letterArr);
text.x = (w - text.getBoundingBox().width) / 2; text.x = (w - text.getBoundingBox().width) / 2;
//text.y = h / 2 - 195 * this.scaleY + 325 * this.scaleY + text.getBoundingBox().height / 2;
text.y = h / 2 - 195 * this.scaleY + 325 * this.scaleY; text.y = h / 2 - 195 * this.scaleY + 325 * this.scaleY;
text.alpha = 0; text.alpha = 0;
let text2 = this.getTextView(answerData.letterArr);
text2.y = h / 2 - 195 * this.scaleY + 325 * this.scaleY + text2.getBoundingBox().height / 2;
text2.x = text.x;
text2.alpha = 0;
answerBg.addChild(text); answerBg.addChild(text);
answerBg.addChild(text2);
answerBg.text = text; answerBg.text = text;
answerBg.text2 = text2;
} }
else { else {
pic.y = h / 2; pic.y = h / 2;
...@@ -481,11 +495,13 @@ export class Exercises { ...@@ -481,11 +495,13 @@ export class Exercises {
if (this.leftAnswer.line) { if (this.leftAnswer.line) {
this.leftAnswer.line.alpha = 1; this.leftAnswer.line.alpha = 1;
this.leftAnswer.text.visible = false; this.leftAnswer.text.visible = false;
this.leftAnswer.text2.alpha = 0;
} }
if (this.rightAnswer.line) { if (this.rightAnswer.line) {
this.rightAnswer.line.alpha = 1; this.rightAnswer.line.alpha = 1;
this.rightAnswer.text.visible = false; this.rightAnswer.text.visible = false;
this.rightAnswer.text2.alpha = 0;
} }
this.curCard = this.frontCard; this.curCard = this.frontCard;
...@@ -495,29 +511,39 @@ export class Exercises { ...@@ -495,29 +511,39 @@ export class Exercises {
} }
textAnimal(text, callback = null){ textAnimal(item, callback = null) {
let labelArr = text.children; let labelArr = item.text.children;
const animal = (label, index) => { const animal = (label, index) => {
tweenChange(label, {y : label.y - 12 * this.scaleY} , 0.08, () => { tweenChange(label, { y: label.y - 12 * this.scaleY }, 0.08, () => {
let i = index + 1; let i = index + 1;
if(labelArr[i]){ if (labelArr[i]) {
animal(labelArr[i], i); animal(labelArr[i], i);
} }
tweenChange(label, {y : label.y + 16 * this.scaleY}, 0.08, () => { tweenChange(label, { y: label.y + 16 * this.scaleY }, 0.08, () => {
tweenChange(label, {y : label.y - 4 * this.scaleY}, 0.04, callback); tweenChange(label, { y: label.y - 4 * this.scaleY }, 0.04, () => {
if (callback) {
callback();
if (index == labelArr.length - 1) {
item.text2.alpha = 1;
item.text.visible = false;
jelly(item.text2, 0.7)
}
}
});
}); });
}); });
} }
item.text2.alpha = 0;
item.text.visible = true;
animal(labelArr[0], 0); animal(labelArr[0], 0);
} }
......
...@@ -958,12 +958,12 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -958,12 +958,12 @@ export class PlayComponent implements OnInit, OnDestroy {
if(item.line.alpha == 1){ if(item.line.alpha == 1){
item.line.alpha = 0; item.line.alpha = 0;
item.text.visible = true; item.text.visible = true;
this.curExer.textAnimal(item.text, ()=>{ this.curExer.textAnimal(item, ()=>{
this.canTouch = true; this.canTouch = true;
}) })
} }
else{ else{
this.curExer.textAnimal(item.text, ()=>{ this.curExer.textAnimal(item, ()=>{
this.canTouch = true; this.canTouch = true;
}) })
this.curAudio = this.playAudio(this.curExer.data.leftAnswer.audioUrl, true); this.curAudio = this.playAudio(this.curExer.data.leftAnswer.audioUrl, true);
...@@ -985,13 +985,13 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -985,13 +985,13 @@ export class PlayComponent implements OnInit, OnDestroy {
if(item.line.alpha == 1){ if(item.line.alpha == 1){
item.line.alpha = 0; item.line.alpha = 0;
item.text.visible = true; item.text.visible = true;
this.curExer.textAnimal(item.text, ()=>{ this.curExer.textAnimal(item, ()=>{
this.canTouch = true; this.canTouch = true;
}) })
} }
else{ else{
this.curExer.textAnimal(item.text, ()=>{ this.curExer.textAnimal(item, ()=>{
this.canTouch = true; this.canTouch = true;
}) })
this.curAudio = this.playAudio(this.curExer.data.rightAnswer.audioUrl, true); this.curAudio = this.playAudio(this.curExer.data.rightAnswer.audioUrl, true);
......
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