Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JM-15
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
JM-15
Commits
72856283
Commit
72856283
authored
Sep 24, 2021
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 替换checker
parent
0b3b634a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
11 deletions
+49
-11
Unit.ts
src/app/play/Unit.ts
+10
-2
checker.ts
src/app/play/checker.ts
+21
-3
play.component.ts
src/app/play/play.component.ts
+18
-6
No files found.
src/app/play/Unit.ts
View file @
72856283
...
...
@@ -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
);
...
...
src/app/play/checker.ts
View file @
72856283
...
...
@@ -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 {
};
}
}
src/app/play/play.component.ts
View file @
72856283
...
...
@@ -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);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment