Commit 72856283 authored by limingzhe's avatar limingzhe

fix: 替换checker

parent 0b3b634a
......@@ -2208,6 +2208,8 @@ export class ScrollView extends MySprite {
const children = this.content.children;
// console.log('children: ', children);
let maxW = 0;
let maxH = 0;
for (let i=0; i<children.length; i++) {
......@@ -2251,15 +2253,21 @@ export class ScrollView extends MySprite {
if (!w) {
w = this.width / 50;
}
const rect1 = this.getBoundingBox();
const rect2 = this.content.getBoundingBox();
let rate = this.height * this.scaleY / this.content.height / this.content.scaleY;
let rate = rect1.height / rect2.height;
// let rate = this.height / this.content.height;
// let rate = this.height * this.scaleY / this.content.height / this.content.scaleY;
if (rate >= 1) {
this._scrollBar.visible = false;
rate = 1;
} else {
this._scrollBar.visible = true;
}
const h = rate * (this.height - this.y)
const h = rate * (this.height)
const r = w / 2;
this._scrollBar.setSize(w, h, r);
......
......@@ -16,6 +16,8 @@ export function checkAnswer(type, string, word) {
return checkDate(string);
case 'word':
return checkWord(string, word);
case 'wordList':
return checkWordInList(string, word);
default:
throw "错误的格式";
}
......@@ -41,7 +43,7 @@ function checkCity(string) {
return {
right: right,
info: '',
info: '专有名词首字母应该大写。',
}
}
......@@ -250,12 +252,27 @@ function checkDate(string: string) {
}
function checkWord(string: string, word: string) {
if (string.trim() != word.trim()) {
return { right: false, info: '' };
if (string.trim() != word.replace(/_/g, " ").trim()) {
return { right: false, info: word.replace(/_/g, " ").trim() };
}
return { right: true, info: '' };
}
function checkWordInList(string: any, word: any) {
const wordList: Array<string> = word;
if (wordList.includes(string)) {
return {
right: wordList.includes(string),
info: '错误的单词。'
};
} else {
return {
right: false,
info: '错误的单词。'
}
}
}
export class WordData {
static _instance = null;
......@@ -291,3 +308,4 @@ export class WordData {
};
}
}
......@@ -877,12 +877,18 @@ export class PlayComponent implements OnInit, OnDestroy {
resultSv.x = -this.resultPanel.width / 2;
resultSv.y = -this.resultPanel.height / 2 + 120;
resultSv.setScrollBarSize(20 * this.mapScale, 5);
resultSv.setContentScale(this.mapScale);
// resultSv.setContentScale(this.mapScale);
this.resultPanel.addChild(resultSv);
this.resultSv = resultSv;
console.log('hotZoneArr: ', this.hotZoneArr);
const tmpLabel = new Label();
tmpLabel.fontSize = 48;
tmpLabel.fontColor = '#ffffff'
tmpLabel.fontName = 'DroidSansFallback';
let baseY = 0 //-500;
for (let i=0; i<this.hotZoneArr.length; i++) {
const richText = new RichText();
......@@ -892,7 +898,7 @@ export class PlayComponent implements OnInit, OnDestroy {
richText.y = baseY + 80;
richText.fontSize = 48;
richText.width = this.resultPanel.width * this.mapScale * 0.9;
richText.width = this.resultPanel.width * 0.9;
richText.fontColor = '#ffffff'
richText.fontName = 'DroidSansFallback';
richText.text = this.hotZoneArr[i].result.userAnswer;
......@@ -904,10 +910,16 @@ export class PlayComponent implements OnInit, OnDestroy {
// const rect = richText.getBoundingBox();
// richText.refreshSize();
const rect = {x: richText.x, y: richText.y, width: richText.width * 0.5, height: richText.fontSize};
tmpLabel.text = richText.text;
tmpLabel.refreshSize();
let rectW = tmpLabel.width < 100 ? 100 : tmpLabel.width;
const rect = {x: richText.x, y: richText.y, width: rectW, height: richText.fontSize};
rect.width += 8;
const addW = 18
rect.width += addW;
rect.height += 16;
// rect.x += addW / 2;
const colorRect = new ShapeRectNew();
colorRect.setSize(rect.width, rect.height, 10);
// colorRect.alpha = 0.3;
......@@ -929,7 +941,7 @@ export class PlayComponent implements OnInit, OnDestroy {
const infoBg = new MySprite();
infoBg.init(this.images.get("info_bg"));
infoBg.y = baseY + 50;
infoBg.x = this.resultPanel.width / 2 * this.mapScale;
infoBg.x = this.resultPanel.width / 2 //* this.mapScale;
resultSv.addItem(infoBg);
// this.resultPanel.addChild(infoBg);
baseY += 130;
......@@ -962,7 +974,7 @@ export class PlayComponent implements OnInit, OnDestroy {
labelAnswer.x = colorRect.width / 2;
labelAnswer.y = colorRect.height / 2;
colorRect.addChild(labelAnswer);
// colorRect.addChild(labelAnswer);
}
......
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