Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
YM5-10
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
YM5-10
Commits
23b72a83
Commit
23b72a83
authored
Jan 28, 2021
by
Chen Jiping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:增加单词动画
parent
f56ac129
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
20 deletions
+109
-20
Exercises.spreat.ts
src/app/play/Exercises.spreat.ts
+90
-6
play.component.ts
src/app/play/play.component.ts
+19
-14
No files found.
src/app/play/Exercises.spreat.ts
View file @
23b72a83
...
@@ -244,6 +244,64 @@ export class Exercises {
...
@@ -244,6 +244,64 @@ export class Exercises {
return
answer
;
return
answer
;
}
}
getTextView2
(
letterArr
){
let
getLabel
=
(
letter
,
fontColor
)
=>
{
const
label
=
new
Label
();
label
.
text
=
letter
;
label
.
textAlign
=
'
center
'
;
label
.
fontSize
=
88
;
label
.
fontName
=
"
MMB
"
;
label
.
fontColor
=
fontColor
;
label
.
setScaleXY
(
this
.
scaleX
);
label
.
refreshSize
();
label
.
y
=
label
.
getBoundingBox
().
height
/
2
;
return
label
;
}
const
bg
=
new
ShapeRect
();
let
h
=
0
;
let
w
=
0
;
let
x
=
0
;
for
(
let
i
=
0
;
i
<
letterArr
.
length
;
++
i
)
{
let
letter
=
letterArr
[
i
];
if
(
!
letter
){
continue
;
}
let
fontColor
=
"
#000000
"
;
if
(
letter
.
isFill
==
'
1
'
)
{
fontColor
=
"
#c8161d
"
;
}
for
(
let
j
=
0
;
j
<
letter
.
val
.
length
;
++
j
){
let
label
=
getLabel
(
letter
.
val
.
charAt
(
j
),
fontColor
);
label
.
x
=
x
;
x
+=
label
.
getBoundingBox
().
width
;
h
=
label
.
getBoundingBox
().
height
;
w
+=
label
.
getBoundingBox
().
width
;
bg
.
addChild
(
label
);
}
}
bg
.
alpha
=
0
;
bg
.
visible
=
false
;
bg
.
setSize
(
w
,
h
);
return
bg
;
}
getAnswerView
(
answerBg
,
answerData
)
{
getAnswerView
(
answerBg
,
answerData
)
{
let
w
=
386
*
this
.
scaleX
;
let
w
=
386
*
this
.
scaleX
;
...
@@ -274,9 +332,10 @@ export class Exercises {
...
@@ -274,9 +332,10 @@ export class Exercises {
answerBg
.
addChild
(
line
);
answerBg
.
addChild
(
line
);
answerBg
.
line
=
line
;
answerBg
.
line
=
line
;
let
text
=
this
.
getTextView
(
answerData
.
letterArr
);
let
text
=
this
.
getTextView
2
(
answerData
.
letterArr
);
text
.
x
=
(
w
-
text
.
getBoundingBox
().
width
)
/
2
;
text
.
x
=
(
w
-
text
.
getBoundingBox
().
width
)
/
2
;
text
.
y
=
h
/
2
-
195
*
this
.
scaleY
+
325
*
this
.
scaleY
+
text
.
getBoundingBox
().
height
/
2
;
//text.y = h / 2 - 195 * this.scaleY + 325 * this.scaleY + text.getBoundingBox().height / 2;
text
.
y
=
h
/
2
-
195
*
this
.
scaleY
+
325
*
this
.
scaleY
;
text
.
alpha
=
0
;
text
.
alpha
=
0
;
answerBg
.
addChild
(
text
);
answerBg
.
addChild
(
text
);
answerBg
.
text
=
text
;
answerBg
.
text
=
text
;
...
@@ -421,14 +480,12 @@ export class Exercises {
...
@@ -421,14 +480,12 @@ export class Exercises {
if
(
this
.
leftAnswer
.
line
)
{
if
(
this
.
leftAnswer
.
line
)
{
this
.
leftAnswer
.
line
.
alpha
=
1
;
this
.
leftAnswer
.
line
.
alpha
=
1
;
this
.
leftAnswer
.
text
.
visible
=
false
;
this
.
leftAnswer
.
text
.
alpha
=
0
;
}
}
if
(
this
.
rightAnswer
.
line
)
{
if
(
this
.
rightAnswer
.
line
)
{
this
.
rightAnswer
.
line
.
alpha
=
1
;
this
.
rightAnswer
.
line
.
alpha
=
1
;
this
.
rightAnswer
.
text
.
visible
=
false
;
this
.
rightAnswer
.
text
.
alpha
=
0
;
}
}
this
.
curCard
=
this
.
frontCard
;
this
.
curCard
=
this
.
frontCard
;
...
@@ -438,4 +495,31 @@ export class Exercises {
...
@@ -438,4 +495,31 @@ export class Exercises {
}
}
textAnimal
(
text
,
callback
=
null
){
let
labelArr
=
text
.
children
;
const
animal
=
(
label
,
index
)
=>
{
tweenChange
(
label
,
{
y
:
label
.
y
-
12
*
this
.
scaleY
}
,
0.08
,
()
=>
{
let
i
=
index
+
1
;
if
(
labelArr
[
i
]){
animal
(
labelArr
[
i
],
i
);
}
tweenChange
(
label
,
{
y
:
label
.
y
+
16
*
this
.
scaleY
},
0.08
,
()
=>
{
tweenChange
(
label
,
{
y
:
label
.
y
-
4
*
this
.
scaleY
},
0.04
,
callback
);
});
});
}
animal
(
labelArr
[
0
],
0
);
}
}
}
\ No newline at end of file
src/app/play/play.component.ts
View file @
23b72a83
...
@@ -951,19 +951,21 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -951,19 +951,21 @@ export class PlayComponent implements OnInit, OnDestroy {
return
;
return
;
}
}
this
.
canTouch
=
false
;
if
(
item
.
line
)
{
if
(
item
.
line
)
{
if
(
item
.
line
.
alpha
==
1
){
if
(
item
.
line
.
alpha
==
1
){
item
.
line
.
alpha
=
0
;
item
.
line
.
alpha
=
0
;
item
.
text
.
visible
=
true
;
t
weenChange
(
item
.
text
,
{
alpha
:
1
},
0.2
,
()
=>
{
t
his
.
curExer
.
textAnimal
(
item
.
text
,
()
=>
{
jelly
(
item
.
text
)
;
this
.
canTouch
=
true
;
})
;
})
}
}
else
{
else
{
t
weenChange
(
item
.
text
,
{
alpha
:
1
},
0.2
,
()
=>
{
t
his
.
curExer
.
textAnimal
(
item
.
text
,
()
=>
{
jelly
(
item
.
text
)
;
this
.
canTouch
=
true
;
})
;
})
this
.
curAudio
=
this
.
playAudio
(
this
.
curExer
.
data
.
leftAnswer
.
audioUrl
,
true
);
this
.
curAudio
=
this
.
playAudio
(
this
.
curExer
.
data
.
leftAnswer
.
audioUrl
,
true
);
}
}
}
}
...
@@ -977,18 +979,21 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -977,18 +979,21 @@ export class PlayComponent implements OnInit, OnDestroy {
return
;
return
;
}
}
this
.
canTouch
=
false
;
if
(
item
.
line
)
{
if
(
item
.
line
)
{
if
(
item
.
line
.
alpha
==
1
){
if
(
item
.
line
.
alpha
==
1
){
item
.
line
.
alpha
=
0
;
item
.
line
.
alpha
=
0
;
item
.
text
.
visible
=
true
;
tweenChange
(
item
.
text
,
{
alpha
:
1
},
0.2
,
()
=>
{
this
.
curExer
.
textAnimal
(
item
.
text
,
()
=>
{
jelly
(
item
.
text
);
this
.
canTouch
=
true
;
});
})
}
}
else
{
else
{
t
weenChange
(
item
.
text
,
{
alpha
:
1
},
0.2
,
()
=>
{
t
his
.
curExer
.
textAnimal
(
item
.
text
,
()
=>
{
jelly
(
item
.
text
)
;
this
.
canTouch
=
true
;
})
;
})
this
.
curAudio
=
this
.
playAudio
(
this
.
curExer
.
data
.
rightAnswer
.
audioUrl
,
true
);
this
.
curAudio
=
this
.
playAudio
(
this
.
curExer
.
data
.
rightAnswer
.
audioUrl
,
true
);
}
}
}
}
...
...
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