Commit c6d88bcc authored by Chen Jiping's avatar Chen Jiping

fix:修复超过界缩入问题;增加横线消失音频

parent 3157ab84
......@@ -25,6 +25,8 @@ class Eexercises {
titleColor = "#5f1782";
wordBg;
init(data, images, scaleX = 1, scaleY = 1) {
......@@ -83,11 +85,12 @@ class Eexercises {
const title = new Label();
title.text = this.data.val;
title.textAlign = 'center';
title.fontSize = 36;
title.fontSize = 56;
title.fontName = "ahronbd-1";
title.fontColor = this.titleColor;
title.setScaleXY(this.scaleX);
title.refreshSize();
title.setMaxSize(300 * this.scaleX);
title.x = this.bg.width / 2;
title.y = this.titleBg.getBoundingBox().height / 2 + 5 * this.scaleY;
......@@ -99,18 +102,35 @@ class Eexercises {
initWord() {
let tw = 0;
let h = 0
for (let i = 0; i < this.data.wordArr.length; ++i) {
let word = this.data.wordArr[i];
let text = this.getWord(word);
tw += text.getBoundingBox().width;
h = text.getBoundingBox().height;
}
let dw = 28 * this.scaleX;
//let dw = 28 * this.scaleX;
let dw = 28;
tw += (this.data.wordArr.length - 1) * dw;
let x = (this.bg.width - tw) / 2;
let scale = this.scaleX;
if (tw >= this.bg.width - 20 * this.scaleX) {
scale = this.bg.width / tw;
}
let wordBg = new ShapeRect();
wordBg.setSize( tw, h);
wordBg.setScaleXY(scale);
wordBg.alpha = 0;
wordBg.x = (this.bg.width - wordBg.getBoundingBox().width) / 2;
wordBg.y = this.bg.height - 30 * this.scaleY - wordBg.getBoundingBox().height;
this.bg.addChild(wordBg);
this.wordBg = wordBg;
//let x = (this.bg.width - tw) / 2;
let x = 0;
for (let i = 0; i < this.wordArr.length; ++i) {
......@@ -121,30 +141,32 @@ class Eexercises {
text.x = x + dw * i;
x += box.width;
text.y = this.bg.height - 30 * this.scaleY - box.height / 2;
text.y = box.height / 2;
const textBg = new ShapeRect();
textBg.setSize(box.width, box.height);
textBg.x = text.x;
textBg.y = text.y - box.height / 2;
textBg.alpha = 0;
this.bg.addChild(textBg);
//this.bg.addChild(textBg);
wordBg.addChild(textBg);
text.textBg = textBg;
if(text.data.isFill == '1'){
let underLine = new Line();
underLine.lineColor = "#949494";
underLine.lineWidth = 3 * this.scaleX;
underLine.lineWidth = 3;
underLine.y = text.y + box.height / 2;
underLine.x = text.x;
underLine.setLine(box.width);
text.underLine = underLine;
this.bg.addChild(underLine);
//this.bg.addChild(underLine);
wordBg.addChild(underLine);
text.alpha = 0;
}
this.bg.addChild(text);
//this.bg.addChild(text);
wordBg.addChild(text);
}
}
......@@ -170,8 +192,8 @@ class Eexercises {
textArr.push(labelText);
}
text.scaleX = this.scaleX;
text.scaleY = this.scaleY;
//text.scaleX = this.scaleX;
//text.scaleY = this.scaleY;
text.refreshSize();
this.wordArr.push(text);
......@@ -182,6 +204,15 @@ class Eexercises {
getImageObj(key) {
return this.images.get(key);
}
resetScale(titleScale, wordScale){
this.title.setScaleXY(titleScale);
this.wordBg.setScaleXY(wordScale);
this.wordBg.y = this.bg.height - 30 * this.scaleY - this.wordBg.getBoundingBox().height;
this.wordBg.x = (this.bg.width - this.wordBg.getBoundingBox().width) / 2;
}
}
export class EexercisesA extends Eexercises {
......
......@@ -311,6 +311,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
audio.play();
this.curAudio = audio;
}
return audio;
......@@ -642,6 +643,10 @@ export class PlayComponent implements OnInit, OnDestroy {
let bgArr = [];
let maxTitleScale = this.mapScale;
let wordScale = this.mapScale;
for (let i = 0; i < this.data.exercisesArr.length; ++i) {
let data = this.data.exercisesArr[i];
......@@ -658,6 +663,14 @@ export class PlayComponent implements OnInit, OnDestroy {
exercises.init(data, this.images, this.mapScale, this.mapScale);
if(maxTitleScale > exercises.title.scaleX){
maxTitleScale = exercises.title.scaleX;
}
if(wordScale > exercises.wordBg.scaleX){
wordScale = exercises.wordBg.scaleX;
}
h = exercises.bg.height;
this.exercisesArr.push(exercises);
......@@ -667,6 +680,11 @@ export class PlayComponent implements OnInit, OnDestroy {
bgArr.push(exercises.bg);
}
//重新设置字体大小
for(let i = 0; i < this.exercisesArr.length; ++ i){
this.exercisesArr[i].resetScale(maxTitleScale, wordScale);
}
//进行排版操作
typesetting(bgArr, 3, this.canvasWidth, this.canvasHeight, h, 14 * this.mapScale, 78 * this.mapScale);
}
......@@ -773,6 +791,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if(word.data.isFill == '1'){
this.playAudio('accompany', true);
if(word.alpha == 0){
word.alpha = 1;
word.underLine.alpha = 0;
......
......@@ -15,7 +15,7 @@ const res = [
const resAudio = [
['click', "assets/play/music/click.mp3"],
['accompany', "assets/play/music/accompany.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