Commit 609c6245 authored by Chen Jiping's avatar Chen Jiping

fix:修复加载时,字线挤在一起的问题

parent 1d4d6152
...@@ -164,6 +164,16 @@ export class Exercises { ...@@ -164,6 +164,16 @@ export class Exercises {
letterObj.isFill = letter.isFill; letterObj.isFill = letter.isFill;
wordObj.letterArr.push(letterObj); wordObj.letterArr.push(letterObj);
}
//重新设置坐标
for(let j = 0; j < wordObj.letterArr.length; ++ j){
let letterObj = wordObj.letterArr[j];
let label = letterObj.letter;
let w = Math.ceil(label.width); let w = Math.ceil(label.width);
tH = Math.ceil(label.height); tH = Math.ceil(label.height);
...@@ -171,10 +181,10 @@ export class Exercises { ...@@ -171,10 +181,10 @@ export class Exercises {
let dw = 3; let dw = 3;
//如果是填空,则增加下划线 //如果是填空,则增加下划线
if (letter.isFill == '1') { if (letterObj.isFill == '1') {
startX += dw; startX += dw;
console.log(startX);
label.x = startX; label.x = startX;
let underLine = new Line(); let underLine = new Line();
...@@ -201,6 +211,7 @@ export class Exercises { ...@@ -201,6 +211,7 @@ export class Exercises {
startX += w; startX += w;
totalW += w; totalW += w;
} }
//不是末位,增加空格 //不是末位,增加空格
......
...@@ -2,8 +2,8 @@ import { Component, ElementRef, ViewChild, OnInit, Input, OnDestroy, HostListene ...@@ -2,8 +2,8 @@ import { Component, ElementRef, ViewChild, OnInit, Input, OnDestroy, HostListene
import { import {
MySprite, MySprite,
ShapeRectNew ShapeRectNew,
Label
} from './Unit'; } from './Unit';
import { res, resAudio } from './resources'; import { res, resAudio } from './resources';
...@@ -638,6 +638,15 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -638,6 +638,15 @@ export class PlayComponent implements OnInit, OnDestroy {
*/ */
initView() { initView() {
//预加载字体
const label = new Label();
label.fontName = "GOTHIC";
label.fontSize = 32;
label.text = 'test';
label.alpha = 1;
label.x = -100;
label.y = -100;
this.renderArr.push(label);
this.initBg(); this.initBg();
...@@ -645,7 +654,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -645,7 +654,10 @@ export class PlayComponent implements OnInit, OnDestroy {
this.initBottomPart(); this.initBottomPart();
this.initExercises(); setTimeout(() => {
this.initExercises();
}, 500);
} }
initBg() { initBg() {
...@@ -908,10 +920,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -908,10 +920,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.curIndex ++; this.curIndex ++;
this.playAudio('right', true, ()=>{ this.playAudio('right', true, ()=>{
let key = 'index_' + index;
this.curAudio = this.audioObj[key];
this.playAudio(key, 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