Commit 72856283 authored by limingzhe's avatar limingzhe

fix: 替换checker

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