Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
YM-42
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
YM-42
Commits
1f78adb8
Commit
1f78adb8
authored
Sep 25, 2020
by
Chen Jiping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修复各种问题
parent
1c024b1d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
37 deletions
+94
-37
Exercises.ts
src/app/play/Exercises.ts
+17
-17
Unit.ts
src/app/play/Unit.ts
+49
-8
play.component.ts
src/app/play/play.component.ts
+28
-12
No files found.
src/app/play/Exercises.ts
View file @
1f78adb8
...
...
@@ -5,7 +5,8 @@ import {
tweenChange
,
ShapeRect
,
Lable2
,
LableText
LableText
,
setFontSize
}
from
'
./Unit
'
;
import
{
...
...
@@ -96,7 +97,7 @@ export class Exercises {
this
.
cardBg
=
cardBg
;
const
bigCard1
=
new
ShapeRectNew
();
bigCard1
.
setOutLine
(
outLineColor
,
2
5
*
scaleY
);
bigCard1
.
setOutLine
(
outLineColor
,
2
0
*
scaleY
);
bigCard1
.
setSize
(
width
,
height
,
25
*
scaleY
);
bigCard1
.
x
=
-
width
/
2
;
bigCard1
.
y
=
-
height
/
2
;
...
...
@@ -185,7 +186,7 @@ export class Exercises {
fontColor
=
"
#cc2a2e
"
;
}
maxWidth
=
bg
.
width
-
110
*
(
this
.
scaleX
>
1
?
1
:
this
.
scaleX
)
;
maxWidth
=
487
*
this
.
scaleX
;
}
else
{
...
...
@@ -196,7 +197,7 @@ export class Exercises {
fontColor
=
"
#cc2a2e
"
;
}
maxWidth
=
bg
.
width
-
190
*
(
this
.
scaleX
>
1
?
1
:
this
.
scaleX
)
;
maxWidth
=
420
*
this
.
scaleX
;
}
labelText
.
fontColor
=
fontColor
;
...
...
@@ -209,8 +210,8 @@ export class Exercises {
text
.
y
=
bg
.
height
/
2
;
bg
.
addChild
(
text
);
console
.
log
(
'
bg.width
'
,
bg
.
width
,
'
maxWidth
'
,
maxWidth
,
'
scaleX
'
,
this
.
scaleX
);
text
.
setMaxSize
(
maxWidth
);
setFontSize
(
maxWidth
,
text
);
text
.
refreshSize
();
totalWidth
=
text
.
getBoundingBox
().
width
;
this
.
textLabel
=
text
;
...
...
@@ -436,7 +437,7 @@ export class Exercises {
textArr
.
push
(
labelText
);
}
text
.
setScaleXY
(
this
.
scaleX
);
text
.
setMaxSize
(
(
960
-
90
)
*
this
.
scaleX
);
text
.
setMaxSize
(
800
*
this
.
scaleX
);
text
.
refreshSize
();
text
.
y
=
bg
.
height
-
text
.
getBoundingBox
().
height
/
2
-
17
*
this
.
scaleY
;
let
totalWidth
=
text
.
getBoundingBox
().
width
;
...
...
@@ -484,8 +485,8 @@ export class Exercises {
private
getColsePic
(
parent
)
{
const
closePic
=
new
MySprite
();
closePic
.
init
(
this
.
images
.
get
(
'
close
'
));
closePic
.
scaleX
=
parent
.
scaleX
;
closePic
.
scaleY
=
parent
.
scaleY
;
closePic
.
scaleX
=
this
.
scaleX
;
closePic
.
scaleY
=
this
.
scaleY
;
closePic
.
x
=
parent
.
width
-
5
*
this
.
scaleX
;
...
...
@@ -498,12 +499,12 @@ export class Exercises {
private
getOverturnPic
(
parent
)
{
const
overturnPic
=
new
MySprite
();
overturnPic
.
init
(
this
.
images
.
get
(
'
overturn
'
));
overturnPic
.
scaleX
=
parent
.
scaleX
;
overturnPic
.
scaleY
=
parent
.
scaleY
;
overturnPic
.
scaleX
=
this
.
scaleX
;
overturnPic
.
scaleY
=
this
.
scaleY
;
overturnPic
.
x
=
parent
.
width
-
28
*
parent
.
scaleX
-
overturnPic
.
getBoundingBox
().
width
/
2
;
overturnPic
.
x
=
parent
.
width
-
18
*
this
.
scaleX
-
overturnPic
.
getBoundingBox
().
width
/
2
;
overturnPic
.
y
=
parent
.
height
-
15
*
parent
.
scaleY
-
overturnPic
.
getBoundingBox
().
height
/
2
;
overturnPic
.
y
=
parent
.
height
-
15
*
this
.
scaleY
-
overturnPic
.
getBoundingBox
().
height
/
2
;
parent
.
addChild
(
overturnPic
);
return
overturnPic
;
...
...
@@ -625,13 +626,12 @@ export class Exercises {
}
resetText
(
scal
e
,
skin
=
'
A
'
)
{
resetText
(
fontSiz
e
,
skin
=
'
A
'
)
{
var
totalWidth
=
0
this
.
textLabel
.
setScaleXY
(
1
);
this
.
textLabel
.
setScaleXY
(
scale
)
;
this
.
textLabel
.
fontSize
=
fontSize
;
this
.
textLabel
.
refreshSize
();
totalWidth
=
this
.
textLabel
.
getBoundingBox
().
width
;
this
.
resetX
(
this
.
textLabel
,
totalWidth
,
skin
);
...
...
src/app/play/Unit.ts
View file @
1f78adb8
...
...
@@ -547,10 +547,7 @@ export class Label extends MySprite {
this
.
_maxWidth
=
w
;
this
.
refreshSize
();
if
(
this
.
width
>=
w
)
{
this
.
scaleX
*=
w
/
this
.
width
;
this
.
scaleY
*=
w
/
this
.
width
;
}
setFontSize
(
this
.
_maxWidth
,
this
);
}
show
(
callBack
=
null
)
{
...
...
@@ -727,10 +724,7 @@ export class Lable2 extends MySprite{
this
.
_maxWidth
=
w
;
this
.
refreshSize
();
if
(
this
.
width
>=
w
)
{
this
.
scaleX
*=
w
/
this
.
width
;
this
.
scaleY
*=
w
/
this
.
width
;
}
setFontSize
(
w
,
this
);
}
show
(
callBack
=
null
)
{
...
...
@@ -1877,3 +1871,50 @@ export function shake(item, time = 0.5, callback = null, rate = 1) {
// --------------- custom class --------------------
/**
* 根据父级组件大小设置字体大小
* @param parWidth
* @param label
*/
export
function
setFontSize
(
maxWidth
:
number
,
label
){
if
(
!
label
){
return
;
}
label
.
refreshSize
();
let
w
=
label
.
getBoundingBox
().
width
;
//如果宽度超过,则缩小字体
if
(
w
>
maxWidth
){
shrinkFont
(
maxWidth
,
label
);
}
}
export
function
shrinkFont
(
maxWidth
:
number
,
label
){
if
(
!
label
){
return
;
}
label
.
refreshSize
();
let
w
=
label
.
getBoundingBox
().
width
;
//如果宽度超过,则缩小字体
if
(
w
>
maxWidth
){
let
fontSize
=
label
.
fontSize
;
fontSize
=
fontSize
-
1
;
label
.
fontSize
=
fontSize
;
label
.
refreshSize
();
shrinkFont
(
maxWidth
,
label
);
}
}
\ No newline at end of file
src/app/play/play.component.ts
View file @
1f78adb8
...
...
@@ -611,8 +611,8 @@ export class PlayComponent implements OnInit, OnDestroy {
const
s
=
Math
.
min
(
sx
,
sy
);
this
.
mapScale
=
s
;
this
.
mapScaleX
=
s
x
;
this
.
mapScaleY
=
s
y
;
this
.
mapScaleX
=
s
;
this
.
mapScaleY
=
s
;
this
.
renderArr
=
[];
...
...
@@ -752,13 +752,19 @@ export class PlayComponent implements OnInit, OnDestroy {
let
startX
=
81
*
this
.
mapScaleX
;
let
startY
=
157
*
this
.
mapScaleY
;
let
tempStartY
=
startY
;
let
midLen
=
this
.
data
.
exercisesArr
.
length
/
2
;
let
lBgArr
=
[];
//如果是A皮肤,则增加长的背景信息
if
(
this
.
data
.
skin
===
'
A
'
)
{
startX
=
(
this
.
canvasWidth
-
1100
*
this
.
mapScale
)
/
2
;
let
height
=
3
*
80
*
this
.
mapScale
+
(
3
-
1
)
*
61
*
this
.
mapScale
;
startY
=
(
this
.
canvasHeight
-
height
)
/
2
;
for
(
let
i
=
0
;
i
<
3
;
++
i
)
{
const
lBg
=
new
ShapeRectNew
();
lBg
.
fillColor
=
"
#E5E3E4
"
;
...
...
@@ -766,8 +772,20 @@ export class PlayComponent implements OnInit, OnDestroy {
lBg
.
setSize
(
1100
*
this
.
mapScale
,
80
*
this
.
mapScale
,
40
*
this
.
mapScale
);
this
.
skinRenderArr
.
push
(
lBg
);
lBgArr
.
push
(
lBg
);
}
}
}
else
{
let
width
=
2
*
560
*
this
.
mapScale
+
25
*
this
.
mapScaleX
;
startX
=
(
this
.
canvasWidth
-
width
)
/
2
;
let
height
=
3
*
96
*
this
.
mapScale
+
(
3
-
1
)
*
78
*
this
.
mapScale
;
startY
=
(
this
.
canvasHeight
-
height
)
/
2
;
}
let
tempStartY
=
startY
;
let
startYArr
=
[];
...
...
@@ -811,7 +829,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
else
{
if
(
this
.
data
.
skin
===
'
A
'
)
{
startY
=
startY
+
exercises
.
bg
.
height
+
6
5
*
this
.
mapScaleY
;
startY
=
startY
+
exercises
.
bg
.
height
+
6
1
*
this
.
mapScaleY
;
}
else
{
startY
=
startY
+
exercises
.
bg
.
height
+
78
*
this
.
mapScaleY
;
...
...
@@ -830,24 +848,22 @@ export class PlayComponent implements OnInit, OnDestroy {
lBgArr
[
i
].
height
=
hight
;
}
let
min
Scale
=
1
;
let
min
FontSize
=
100
;
//获取最小字体
for
(
let
i
=
0
;
i
<
this
.
exercisesArr
.
length
;
++
i
)
{
let
textLabel
=
this
.
exercisesArr
[
i
].
textLabel
;
if
(
min
Scale
>
textLabel
.
scaleX
)
{
min
Scale
=
textLabel
.
scaleX
;
if
(
min
FontSize
>
textLabel
.
fontSize
)
{
min
FontSize
=
textLabel
.
fontSize
;
}
}
console
.
log
(
minScale
);
for
(
let
i
=
0
;
i
<
this
.
exercisesArr
.
length
;
++
i
)
{
this
.
exercisesArr
[
i
].
resetText
(
min
Scal
e
,
this
.
data
.
skin
);
this
.
exercisesArr
[
i
].
resetText
(
min
FontSiz
e
,
this
.
data
.
skin
);
}
const
mask
=
new
ShapeRect
();
...
...
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