Commit de1fdac1 authored by limingzhe's avatar limingzhe

feat: 更改子模板跳转 字体加载

parent 397452a5
......@@ -2,19 +2,19 @@
export async function loadFonts () {
export async function loadFonts (fontName, fontFile) {
// const font = new FontFace(
// "DroidSansFallback",
// "url(" + "../../assets/play/font/DroidSansFallback.ttf" + ")"
// );
try {
console.log(location.href.split("#")[0] + "assets/play/font/DroidSansFallback.ttf");
console.log(location.href.split("#")[0] + "assets/play/font/" + fontFile);
const font = new FontFace(
"DroidSansFallback",
"url(" + location.href.split("#")[0] + "assets/play/font/DroidSansFallback.ttf" + ")"
fontName,
"url(" + location.href.split("#")[0] + "assets/play/font/" + fontFile + ")"
);
console.log('start: ', new Date().getTime())
......@@ -22,6 +22,9 @@ export async function loadFonts () {
console.log('end: ', new Date().getTime())
document.fonts.add(font);
document.body.classList.add("fonts-loaded");
} catch (error) {
console.log(error);
}
......
<span style="font-family:'BRLNSDB'" ></span>
<span style="font-family:'DroidSansFallback'" ></span>
<span style="font-family:'Aileron-Black'" ></span>
<div class="game-container" #wrap>
<canvas id="canvas" style="width: 100%; height: 100%;" #canvas></canvas>
......@@ -6,7 +7,7 @@
<div #iframeContent style="position: absolute; top: 0;">
<div *ngFor="let t of templateArr; let i = index">
<iframe *ngIf="t.isShow" [src]="t.playUrl || ''" style="width: 100vw; height: 100vh; border: 0px solid #ccc; padding: 5px;" frameborder="0">
<iframe *ngIf="t.isShow" [src]="t.playUrl || ''" style="width: 100vw; height: 100vh; border: 0px solid #ccc; " frameborder="0">
</iframe>
</div>
</div>
......
......@@ -140,9 +140,10 @@ export class PlayComponent implements OnInit, OnDestroy {
async ngOnInit() {
await loadFonts();
// await loadFonts();
const getData = (<any>window).courseware.getData;
getData((data, aspect) => {
......@@ -438,11 +439,23 @@ export class PlayComponent implements OnInit, OnDestroy {
// 预加载资源
this.loadResources().then(() => {
// this.setfontData();
this.addServerListener();
window['air'].hideAirClassLoading(this.KEY, this.data);
console.log('aaaaaa');
loadFonts('DroidSansFallback', 'DroidSansFallback.ttf').then(() => {
console.log('bbbbb');
loadFonts('Aileron-Black', 'Aileron-Black.ttf').then(() => {
console.log('cccc');
this.addServerListener();
window['air'].hideAirClassLoading(this.KEY, this.data);
})
})
});
......@@ -901,7 +914,7 @@ export class PlayComponent implements OnInit, OnDestroy {
btnLabel.fontSize = 64;
btnLabel.fontName = 'Aileron-Black';
btnLabel.textAlign = 'center';
btnLabel.text = 'Sent';
btnLabel.text = 'Send';
btnLabel.y = 5;
btnLabel.fontColor = '#ffffff';
btn.addChild(btnLabel, 3);
......@@ -980,6 +993,8 @@ export class PlayComponent implements OnInit, OnDestroy {
console.log('rect.height: ', rect.height);
colorRect.alpha = 0;
richText.addChild(colorRect);
this.sentenceEmptyArr.push(colorRect);
......@@ -1313,6 +1328,8 @@ export class PlayComponent implements OnInit, OnDestroy {
mapMove(event) {
event.preventDefault()
if (!this.curMoveItem) {
return;
}
......@@ -1328,6 +1345,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.curMoveItem.x += this.curMoveItem.moveOffX;
this.curMoveItem.y += this.curMoveItem.moveOffY;
}
}
......@@ -1350,11 +1369,14 @@ export class PlayComponent implements OnInit, OnDestroy {
}
checkShowSubTemplateOne() {
if (this.submitCount == 1) {
this.showSubTemplate(1);
} else {
this.showSubTemplate(0);
}
this.showSubTemplate(0);
// if (this.submitCount == 1) {
// this.showSubTemplate(1);
// } else {
// this.showSubTemplate(0);
// }
}
......@@ -1611,6 +1633,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
showSubTemplate(index) {
console.log('showSubTemplate _ ', index);
const arr = this.templateArr;
for (let i=0; i<arr.length; i++) {
arr[i].isShow = false;
......@@ -1673,8 +1696,8 @@ export class PlayComponent implements OnInit, OnDestroy {
// }, 300);
}
if (msgData.action === "sendResult") {
if (msgData.action === "temp_send_result") {
console.log('in temp_send_result __ msgData: ', msgData);
}
......
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