Commit a39e3835 authored by Chen Jiping's avatar Chen Jiping

fix:调整动画显示方式

parent 23b72a83
......@@ -62,6 +62,7 @@ export class Exercises {
this.initIndex();
this.initCard();
}
initBg() {
......@@ -244,9 +245,9 @@ export class Exercises {
return answer;
}
getTextView2(letterArr){
getTextView2(letterArr) {
let getLabel =(letter, fontColor)=>{
let getLabel = (letter, fontColor) => {
const label = new Label();
label.text = letter;
......@@ -261,18 +262,20 @@ export class Exercises {
}
const bg = new ShapeRect();
let h = 0;
let w = 0;
let x = 0;
let tmpArr = [];
for (let i = 0; i < letterArr.length; ++i) {
let letter = letterArr[i];
if(!letter){
if (!letter) {
continue;
}
......@@ -281,18 +284,22 @@ export class Exercises {
if (letter.isFill == '1') {
fontColor = "#c8161d";
}
for(let j = 0; j < letter.val.length; ++ j){
let label = getLabel(letter.val.charAt(j), fontColor);
label.x = x;
x += label.getBoundingBox().width;
h = label.getBoundingBox().height;
w += label.getBoundingBox().width;
for (let j = 0; j < letter.val.length; ++j) {
let label = getLabel(letter.val.charAt(j), fontColor);
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;
......@@ -334,11 +341,18 @@ export class Exercises {
let text = this.getTextView2(answerData.letterArr);
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.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(text2);
answerBg.text = text;
answerBg.text2 = text2;
}
else {
pic.y = h / 2;
......@@ -481,11 +495,13 @@ export class Exercises {
if (this.leftAnswer.line) {
this.leftAnswer.line.alpha = 1;
this.leftAnswer.text.visible = false;
this.leftAnswer.text2.alpha = 0;
}
if (this.rightAnswer.line) {
this.rightAnswer.line.alpha = 1;
this.rightAnswer.text.visible = false;
this.rightAnswer.text2.alpha = 0;
}
this.curCard = this.frontCard;
......@@ -495,31 +511,41 @@ export class Exercises {
}
textAnimal(text, callback = null){
textAnimal(item, callback = null) {
let labelArr = text.children;
let labelArr = item.text.children;
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;
if(labelArr[i]){
if (labelArr[i]) {
animal(labelArr[i], i);
}
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 + 16 * this.scaleY }, 0.08, () => {
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);
}
}
\ No newline at end of file
......@@ -958,12 +958,12 @@ export class PlayComponent implements OnInit, OnDestroy {
if(item.line.alpha == 1){
item.line.alpha = 0;
item.text.visible = true;
this.curExer.textAnimal(item.text, ()=>{
this.curExer.textAnimal(item, ()=>{
this.canTouch = true;
})
}
else{
this.curExer.textAnimal(item.text, ()=>{
this.curExer.textAnimal(item, ()=>{
this.canTouch = true;
})
this.curAudio = this.playAudio(this.curExer.data.leftAnswer.audioUrl, true);
......@@ -985,13 +985,13 @@ export class PlayComponent implements OnInit, OnDestroy {
if(item.line.alpha == 1){
item.line.alpha = 0;
item.text.visible = true;
this.curExer.textAnimal(item.text, ()=>{
this.curExer.textAnimal(item, ()=>{
this.canTouch = true;
})
}
else{
this.curExer.textAnimal(item.text, ()=>{
this.curExer.textAnimal(item, ()=>{
this.canTouch = 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