Commit 1c024b1d authored by Chen Jiping's avatar Chen Jiping

fix:修复问题

parent b9442cb9
......@@ -127,46 +127,6 @@ export class Exercises {
cardBg.setScaleXY(0);
}
/**
* 设置最大的宽度,并返回新的最大宽度
* @param textLabelArr
* @param w
*/
private setMaxScale(textLabelArr, w){
let scale = 1;
let width = 0;
for(let i = 0; i < textLabelArr.length; ++i){
var textLabel = textLabelArr[i];
width += textLabel.getBoundingBox().width;
scale = textLabel.scaleX;
}
if(width >= w){
scale *= w / width;
}
else{
return width;
}
width = 0;
//设置scale,并重新计算宽度
for(let i = 0; i < textLabelArr.length; ++i){
var textLabel = textLabelArr[i];
textLabel.setScaleXY(scale);
textLabel.refreshSize();
width += textLabel.getBoundingBox().width;
}
return width;
}
/**
* 设置x坐标
* @param textLabel
......@@ -206,6 +166,8 @@ export class Exercises {
let textArr = new Array<LableText>();
text.textArr = textArr;
let maxWidth = 0;
for (let i = 0; i < this.exercisesData.letters.length; ++i) {
var letter = this.exercisesData.letters[i];
......@@ -223,6 +185,7 @@ export class Exercises {
fontColor = "#cc2a2e";
}
maxWidth = bg.width - 110 * (this.scaleX > 1 ? 1 : this.scaleX);
}
else {
......@@ -232,20 +195,24 @@ export class Exercises {
else {
fontColor = "#cc2a2e";
}
maxWidth = bg.width - 190 * (this.scaleX > 1 ? 1 : this.scaleX);
}
labelText.fontColor = fontColor;
textArr.push(labelText);
}
text.setScaleXY(this.scaleX);
text.refreshSize();
text.scaleX = this.scaleX;
text.scaleY = this.scaleY;
text.y = bg.height / 2;
totalWidth = text.getBoundingBox().width;
bg.addChild(text);
text.setMaxSize(bg.width - 110 * this.scaleX);
console.log('bg.width', bg.width, 'maxWidth', maxWidth, 'scaleX', this.scaleX);
text.setMaxSize(maxWidth);
text.refreshSize();
totalWidth = text.getBoundingBox().width;
this.textLabel = text;
this.resetX(text, totalWidth, this.skin);
......@@ -291,7 +258,7 @@ export class Exercises {
index.scaleX = this.scaleX;
index.scaleY = this.scaleY;
index.setMaxSize(indexBg.width);
index.x = - index.width / 2;
index.x = - index.getBoundingBox().width / 2;
indexBg.addChild(index);
//内容
......@@ -335,7 +302,7 @@ export class Exercises {
index.fontColor = '#ec6101';
index.setScaleXY(this.scaleX);
index.setMaxSize(45 * scaleX);
index.x = indexBg.x - index.width / 2;
index.x = indexBg.x - index.getBoundingBox().width / 2;
index.y = height / 2;
bg.addChild(index);
......@@ -471,7 +438,7 @@ export class Exercises {
text.setScaleXY(this.scaleX);
text.setMaxSize((960 - 90) * this.scaleX);
text.refreshSize();
text.y = bg.height - text.getBoundingBox().height / 2 - 7 * this.scaleY;
text.y = bg.height - text.getBoundingBox().height / 2 - 17 * this.scaleY;
let totalWidth = text.getBoundingBox().width;
text.x = (bg.width - totalWidth) / 2;
......@@ -661,7 +628,7 @@ export class Exercises {
resetText(scale, skin = 'A') {
var totalWidth = 0
this.textLabel.setScaleXY(1);
this.textLabel.setScaleXY(scale);
this.textLabel.refreshSize();
......
......@@ -74,6 +74,13 @@ export class Listening {
return null;
}
reset(){
this.btnPlay.alpha = 1;
this.btnStop.alpha = 0;
this.playing = false;
}
playAudio(callback = null){
this.btnPlay.alpha = 0;
......
......@@ -36,8 +36,8 @@ export class Title {
//初始化标题1背景
const titePart1Bg = new ShapeRect();
titePart1Bg.fillColor="#567790";
let pWidth = 121 * mapScaleX;
let pHeight = 69 * mapScaleY;
let pWidth = 117 * mapScaleX;
let pHeight = 65 * mapScaleY;
titePart1Bg.setSize(pWidth, pHeight);
titePart1Bg.setShadow(4,4,0, 'rgba(0, 0, 0, 0.2)');
titePart1Bg.x = 0;
......@@ -54,6 +54,7 @@ export class Title {
part1.setScaleXY(mapScaleX);
part1.refreshSize();
part1.x = pWidth - part1.getBoundingBox().width - 13 * mapScaleX;
part1.y = 5 * mapScaleY + part1.getBoundingBox().height / 2;
titleBg.addChild(part1);
//标题2内容
......@@ -65,21 +66,16 @@ export class Title {
part2.setScaleXY(mapScaleX);
part2.refreshSize();
part2.x = titePart1Bg.getBoundingBox().width + 11 * mapScaleX;
part2.y = 10 * mapScaleY + part2.getBoundingBox().height / 2;
part2.y = 16 * mapScaleY + part2.getBoundingBox().height / 2;
let height = Math.max(titePart1Bg.getBoundingBox().height, part2.getBoundingBox().height);
let width = titePart1Bg.getBoundingBox().width + part2.getBoundingBox().width + 11 * mapScaleX;
titePart1Bg.y = (height - pHeight)/2;
part1.y = height / 2;
titleBg.setSize(width, height);
titleBg.alpha = 0;
part2.y = height / 2;
titleBg.addChild(part2);
this.titleBg = titleBg;
......
......@@ -641,7 +641,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
initBg() {
console.log(this.images);
const getPic = (key, anchorX: number = 0.5, anchorY: number = 0.5) => {
const pic = new MySprite();
pic.init(this.images.get(key), anchorX, anchorY);
......@@ -651,7 +651,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
const initBg = (skin, skinType) => {
console.log(skin);
//左上
if (skin.lt_pic_url) {
const pic = getPic(skinType + '_' + skin.lt_pic_url, 0, 0);
......@@ -825,8 +825,6 @@ export class PlayComponent implements OnInit, OnDestroy {
this.bigCardRenderArr.push(exercises.cardBg);
}
console.log(startYArr);
for(let i = 0; i < lBgArr.length; ++ i){
lBgArr[i].y = startYArr[i];
lBgArr[i].height = hight ;
......@@ -845,6 +843,8 @@ export class PlayComponent implements OnInit, OnDestroy {
}
console.log(minScale);
for (let i = 0; i < this.exercisesArr.length; ++i) {
this.exercisesArr[i].resetText(minScale, this.data.skin);
......@@ -873,7 +873,9 @@ export class PlayComponent implements OnInit, OnDestroy {
if (this.checkClickTarget(this.listening.bg)) {
this.curAudio = this.listening.play();
this.curAudio = this.listening.play(()=>{
this.listening.reset();
});
return;
}
......
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