Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cocosTest
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
cocosTest
Commits
eadcabdc
Commit
eadcabdc
authored
Feb 26, 2020
by
liujiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ts error, upgrade lastest unit.ts
parent
21870381
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
155 additions
and
77 deletions
+155
-77
Unit.ts
src/app/play/Unit.ts
+155
-77
No files found.
src/app/play/Unit.ts
View file @
eadcabdc
import
TWEEN
from
'
@tweenjs/tween.js
'
;
import
TWEEN
from
'
@tweenjs/tween.js
'
;
interface
AirWindow
extends
Window
{
air
:
any
;
curCtx
:
any
;
}
declare
let
window
:
AirWindow
;
class
Sprite
{
class
Sprite
{
x
=
0
;
x
=
0
;
...
@@ -15,7 +19,7 @@ class Sprite {
...
@@ -15,7 +19,7 @@ class Sprite {
constructor
(
ctx
=
null
)
{
constructor
(
ctx
=
null
)
{
if
(
!
ctx
)
{
if
(
!
ctx
)
{
this
.
ctx
=
(
window
as
any
)
.
curCtx
;
this
.
ctx
=
window
.
curCtx
;
}
else
{
}
else
{
this
.
ctx
=
ctx
;
this
.
ctx
=
ctx
;
}
}
...
@@ -66,7 +70,7 @@ export class MySprite extends Sprite {
...
@@ -66,7 +70,7 @@ export class MySprite extends Sprite {
_z
=
0
;
_z
=
0
;
init
(
imgObj
=
null
,
anchorX
:
number
=
0.5
,
anchorY
:
number
=
0.5
)
{
init
(
imgObj
=
null
,
anchorX
:
number
=
0.5
,
anchorY
:
number
=
0.5
)
{
if
(
imgObj
)
{
if
(
imgObj
)
{
...
@@ -184,16 +188,13 @@ export class MySprite extends Sprite {
...
@@ -184,16 +188,13 @@ export class MySprite extends Sprite {
if
(
this
.
children
.
length
<=
0
)
{
return
;
}
if
(
this
.
children
.
length
<=
0
)
{
return
;
}
for
(
let
i
=
0
;
i
<
this
.
children
.
length
;
i
++
)
{
for
(
const
child
of
this
.
children
)
{
if
(
child
===
this
)
{
if
(
this
.
children
[
i
]
===
this
)
{
if
(
this
.
visible
)
{
if
(
this
.
visible
)
{
this
.
drawSelf
();
this
.
drawSelf
();
}
}
}
else
{
}
else
{
child
.
update
();
this
.
children
[
i
].
update
();
}
}
}
}
}
}
...
@@ -240,7 +241,7 @@ export class MySprite extends Sprite {
...
@@ -240,7 +241,7 @@ export class MySprite extends Sprite {
removeChildren
()
{
removeChildren
()
{
for
(
let
i
=
0
;
i
<
this
.
children
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
children
.
length
;
i
++
)
{
if
(
this
.
children
[
i
])
{
if
(
this
.
children
[
i
])
{
if
(
this
.
children
[
i
]
!=
this
)
{
if
(
this
.
children
[
i
]
!=
=
this
)
{
this
.
children
.
splice
(
i
,
1
);
this
.
children
.
splice
(
i
,
1
);
i
--
;
i
--
;
}
}
...
@@ -249,9 +250,9 @@ export class MySprite extends Sprite {
...
@@ -249,9 +250,9 @@ export class MySprite extends Sprite {
}
}
_changeChildAlpha
(
alpha
)
{
_changeChildAlpha
(
alpha
)
{
for
(
let
i
=
0
;
i
<
this
.
children
.
length
;
i
++
)
{
for
(
const
child
of
this
.
children
)
{
if
(
this
.
children
[
i
]
!
=
this
)
{
if
(
child
!=
=
this
)
{
this
.
children
[
i
]
.
alpha
=
alpha
;
child
.
alpha
=
alpha
;
}
}
}
}
}
}
...
@@ -362,7 +363,7 @@ export class ColorSpr extends MySprite {
...
@@ -362,7 +363,7 @@ export class ColorSpr extends MySprite {
g
=
0
;
g
=
0
;
b
=
0
;
b
=
0
;
createGSCanvas
(){
createGSCanvas
()
{
if
(
!
this
.
img
)
{
if
(
!
this
.
img
)
{
return
;
return
;
...
@@ -377,8 +378,8 @@ export class ColorSpr extends MySprite {
...
@@ -377,8 +378,8 @@ export class ColorSpr extends MySprite {
const
c
=
this
.
ctx
.
getImageData
(
rect
.
x
,
rect
.
y
,
rect
.
width
,
rect
.
height
);
const
c
=
this
.
ctx
.
getImageData
(
rect
.
x
,
rect
.
y
,
rect
.
width
,
rect
.
height
);
for
(
let
i
=
0
;
i
<
c
.
height
;
i
++
)
{
for
(
let
i
=
0
;
i
<
c
.
height
;
i
++
)
{
for
(
let
j
=
0
;
j
<
c
.
width
;
j
++
)
{
for
(
let
j
=
0
;
j
<
c
.
width
;
j
++
)
{
const
x
=
(
i
*
4
)
*
c
.
width
+
(
j
*
4
);
const
x
=
(
i
*
4
)
*
c
.
width
+
(
j
*
4
);
const
r
=
c
.
data
[
x
];
const
r
=
c
.
data
[
x
];
...
@@ -412,7 +413,7 @@ export class GrayscaleSpr extends MySprite {
...
@@ -412,7 +413,7 @@ export class GrayscaleSpr extends MySprite {
grayScale
=
120
;
grayScale
=
120
;
createGSCanvas
(){
createGSCanvas
()
{
if
(
!
this
.
img
)
{
if
(
!
this
.
img
)
{
return
;
return
;
...
@@ -423,8 +424,8 @@ export class GrayscaleSpr extends MySprite {
...
@@ -423,8 +424,8 @@ export class GrayscaleSpr extends MySprite {
const
rect
=
this
.
getBoundingBox
();
const
rect
=
this
.
getBoundingBox
();
const
c
=
this
.
ctx
.
getImageData
(
rect
.
x
,
rect
.
y
,
rect
.
width
,
rect
.
height
);
const
c
=
this
.
ctx
.
getImageData
(
rect
.
x
,
rect
.
y
,
rect
.
width
,
rect
.
height
);
for
(
let
i
=
0
;
i
<
c
.
height
;
i
++
)
{
for
(
let
i
=
0
;
i
<
c
.
height
;
i
++
)
{
for
(
let
j
=
0
;
j
<
c
.
width
;
j
++
)
{
for
(
let
j
=
0
;
j
<
c
.
width
;
j
++
)
{
const
x
=
(
i
*
4
)
*
c
.
width
+
(
j
*
4
);
const
x
=
(
i
*
4
)
*
c
.
width
+
(
j
*
4
);
const
r
=
c
.
data
[
x
];
const
r
=
c
.
data
[
x
];
...
@@ -467,10 +468,10 @@ export class BitMapLabel extends MySprite {
...
@@ -467,10 +468,10 @@ export class BitMapLabel extends MySprite {
const
tmpArr
=
text
.
split
(
''
);
const
tmpArr
=
text
.
split
(
''
);
let
totalW
=
0
;
let
totalW
=
0
;
let
h
=
0
;
let
h
=
0
;
for
(
let
i
=
0
;
i
<
tmpArr
.
length
;
i
++
)
{
for
(
const
tmp
of
tmpArr
)
{
const
label
=
new
MySprite
(
this
.
ctx
);
const
label
=
new
MySprite
(
this
.
ctx
);
label
.
init
(
data
[
tmp
Arr
[
i
]
],
0
);
label
.
init
(
data
[
tmp
],
0
);
this
.
addChild
(
label
);
this
.
addChild
(
label
);
labelArr
.
push
(
label
);
labelArr
.
push
(
label
);
...
@@ -483,9 +484,9 @@ export class BitMapLabel extends MySprite {
...
@@ -483,9 +484,9 @@ export class BitMapLabel extends MySprite {
this
.
height
=
h
;
this
.
height
=
h
;
let
offX
=
-
totalW
/
2
;
let
offX
=
-
totalW
/
2
;
for
(
let
i
=
0
;
i
<
labelArr
.
length
;
i
++
)
{
for
(
const
label
of
labelArr
)
{
label
Arr
[
i
]
.
x
=
offX
;
label
.
x
=
offX
;
offX
+=
label
Arr
[
i
]
.
width
;
offX
+=
label
.
width
;
}
}
this
.
labelArr
=
labelArr
;
this
.
labelArr
=
labelArr
;
...
@@ -498,10 +499,10 @@ export class BitMapLabel extends MySprite {
...
@@ -498,10 +499,10 @@ export class BitMapLabel extends MySprite {
export
class
Label
extends
MySprite
{
export
class
Label
extends
MySprite
{
text
:
S
tring
;
text
:
s
tring
;
// fontSize:String = '40px';
// fontSize:String = '40px';
fontName
:
String
=
'
Verdana
'
;
fontName
=
'
Verdana
'
;
textAlign
:
String
=
'
left
'
;
textAlign
=
'
left
'
;
fontSize
=
40
;
fontSize
=
40
;
fontColor
=
'
#000000
'
;
fontColor
=
'
#000000
'
;
fontWeight
=
900
;
fontWeight
=
900
;
...
@@ -563,7 +564,7 @@ export class Label extends MySprite {
...
@@ -563,7 +564,7 @@ export class Label extends MySprite {
const
tween
=
new
TWEEN
.
Tween
(
this
)
const
tween
=
new
TWEEN
.
Tween
(
this
)
.
to
({
alpha
:
1
},
800
)
.
to
({
alpha
:
1
},
800
)
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
.
onComplete
(
function
()
{
.
onComplete
(
()
=>
{
if
(
callBack
)
{
if
(
callBack
)
{
callBack
();
callBack
();
}
}
...
@@ -649,11 +650,10 @@ export class RichTextOld extends Label {
...
@@ -649,11 +650,10 @@ export class RichTextOld extends Label {
textArr
=
[];
textArr
=
[];
fontSize
=
40
;
fontSize
=
40
;
setText
(
text
:
string
,
words
)
{
setText
(
text
:
string
,
words
)
{
let
newText
=
text
;
let
newText
=
text
;
for
(
let
i
=
0
;
i
<
words
.
length
;
i
++
)
{
for
(
const
word
of
words
)
{
const
word
=
words
[
i
];
const
re
=
new
RegExp
(
word
,
'
g
'
);
const
re
=
new
RegExp
(
word
,
'
g
'
);
newText
=
newText
.
replace
(
re
,
`#
${
word
}
#`
);
newText
=
newText
.
replace
(
re
,
`#
${
word
}
#`
);
...
@@ -676,8 +676,8 @@ export class RichTextOld extends Label {
...
@@ -676,8 +676,8 @@ export class RichTextOld extends Label {
this
.
ctx
.
fontWeight
=
this
.
fontWeight
;
this
.
ctx
.
fontWeight
=
this
.
fontWeight
;
let
curX
=
0
;
let
curX
=
0
;
for
(
let
i
=
0
;
i
<
this
.
textArr
.
length
;
i
++
)
{
for
(
const
text
of
this
.
textArr
)
{
const
w
=
this
.
ctx
.
measureText
(
t
his
.
textArr
[
i
]
).
width
;
const
w
=
this
.
ctx
.
measureText
(
t
ext
).
width
;
curX
+=
w
;
curX
+=
w
;
}
}
...
@@ -699,7 +699,7 @@ export class RichTextOld extends Label {
...
@@ -699,7 +699,7 @@ export class RichTextOld extends Label {
const
tween
=
new
TWEEN
.
Tween
(
this
)
const
tween
=
new
TWEEN
.
Tween
(
this
)
.
to
({
alpha
:
1
},
800
)
.
to
({
alpha
:
1
},
800
)
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
.
onComplete
(
function
()
{
.
onComplete
(
()
=>
{
if
(
callBack
)
{
if
(
callBack
)
{
callBack
();
callBack
();
}
}
...
@@ -735,7 +735,7 @@ export class RichTextOld extends Label {
...
@@ -735,7 +735,7 @@ export class RichTextOld extends Label {
const
w
=
this
.
ctx
.
measureText
(
this
.
textArr
[
i
]).
width
;
const
w
=
this
.
ctx
.
measureText
(
this
.
textArr
[
i
]).
width
;
if
((
i
+
1
)
%
2
==
0
)
{
if
((
i
+
1
)
%
2
==
=
0
)
{
this
.
ctx
.
fillStyle
=
'
#c8171e
'
;
this
.
ctx
.
fillStyle
=
'
#c8171e
'
;
}
else
{
}
else
{
this
.
ctx
.
fillStyle
=
'
#000000
'
;
this
.
ctx
.
fillStyle
=
'
#000000
'
;
...
@@ -760,7 +760,7 @@ export class RichText extends Label {
...
@@ -760,7 +760,7 @@ export class RichText extends Label {
disH
=
30
;
disH
=
30
;
constructor
(
ctx
)
{
constructor
(
ctx
?:
any
)
{
super
(
ctx
);
super
(
ctx
);
// this.dataArr = dataArr;
// this.dataArr = dataArr;
...
@@ -794,12 +794,12 @@ export class RichText extends Label {
...
@@ -794,12 +794,12 @@ export class RichText extends Label {
for
(
let
a
=
0
;
a
<
chr
.
length
;
a
++
)
{
for
(
const
c
of
chr
)
{
if
(
this
.
ctx
.
measureText
(
temp
).
width
<
w
&&
this
.
ctx
.
measureText
(
temp
+
(
c
hr
[
a
]
)).
width
<=
w
)
{
if
(
this
.
ctx
.
measureText
(
temp
).
width
<
w
&&
this
.
ctx
.
measureText
(
temp
+
(
c
)).
width
<=
w
)
{
temp
+=
'
'
+
c
hr
[
a
]
;
temp
+=
'
'
+
c
;
}
else
{
}
else
{
row
.
push
(
temp
);
row
.
push
(
temp
);
temp
=
'
'
+
c
hr
[
a
]
;
temp
=
'
'
+
c
;
}
}
}
}
row
.
push
(
temp
);
row
.
push
(
temp
);
...
@@ -841,7 +841,7 @@ export class RichText extends Label {
...
@@ -841,7 +841,7 @@ export class RichText extends Label {
export
class
LineRect
extends
MySprite
{
export
class
LineRect
extends
MySprite
{
lineColor
=
"
#ffffff
"
;
lineColor
=
'
#ffffff
'
;
lineWidth
=
10
;
lineWidth
=
10
;
setSize
(
w
,
h
)
{
setSize
(
w
,
h
)
{
...
@@ -931,7 +931,83 @@ export class ShapeCircle extends MySprite {
...
@@ -931,7 +931,83 @@ export class ShapeCircle extends MySprite {
}
}
}
}
export
class
ShapeRectNew
extends
MySprite
{
radius
=
0
;
fillColor
=
'
#ffffff
'
;
strokeColor
=
'
#000000
'
;
fill
=
true
;
stroke
=
false
;
lineWidth
=
1
;
setSize
(
w
,
h
,
r
)
{
this
.
width
=
w
;
this
.
height
=
h
;
this
.
radius
=
r
;
}
setOutLine
(
color
,
lineWidth
)
{
this
.
stroke
=
true
;
this
.
strokeColor
=
color
;
this
.
lineWidth
=
lineWidth
;
}
drawShape
()
{
const
ctx
=
this
.
ctx
;
const
width
=
this
.
width
;
const
height
=
this
.
height
;
const
radius
=
this
.
radius
;
ctx
.
save
();
ctx
.
beginPath
(
0
);
// 从右下角顺时针绘制,弧度从0到1/2PI
ctx
.
arc
(
width
-
radius
,
height
-
radius
,
radius
,
0
,
Math
.
PI
/
2
);
// 矩形下边线
ctx
.
lineTo
(
radius
,
height
);
// 左下角圆弧,弧度从1/2PI到PI
ctx
.
arc
(
radius
,
height
-
radius
,
radius
,
Math
.
PI
/
2
,
Math
.
PI
);
// 矩形左边线
ctx
.
lineTo
(
0
,
radius
);
// 左上角圆弧,弧度从PI到3/2PI
ctx
.
arc
(
radius
,
radius
,
radius
,
Math
.
PI
,
Math
.
PI
*
3
/
2
);
// 上边线
ctx
.
lineTo
(
width
-
radius
,
0
);
// 右上角圆弧
ctx
.
arc
(
width
-
radius
,
radius
,
radius
,
Math
.
PI
*
3
/
2
,
Math
.
PI
*
2
);
// 右边线
ctx
.
lineTo
(
width
,
height
-
radius
);
ctx
.
closePath
();
if
(
this
.
fill
)
{
ctx
.
fillStyle
=
this
.
fillColor
;
ctx
.
fill
();
}
if
(
this
.
stroke
)
{
ctx
.
lineWidth
=
this
.
lineWidth
;
ctx
.
strokeStyle
=
this
.
strokeColor
;
ctx
.
stroke
();
}
ctx
.
restore
();
}
drawSelf
()
{
super
.
drawSelf
();
this
.
drawShape
();
}
}
export
class
MyAnimation
extends
MySprite
{
export
class
MyAnimation
extends
MySprite
{
...
@@ -978,13 +1054,13 @@ export class MyAnimation extends MySprite {
...
@@ -978,13 +1054,13 @@ export class MyAnimation extends MySprite {
this
.
frameArr
[
this
.
frameIndex
].
visible
=
true
;
this
.
frameArr
[
this
.
frameIndex
].
visible
=
true
;
}
}
_refreshSize
(
img
)
{
_refreshSize
(
img
:
any
)
{
if
(
this
.
width
<
img
[
'
width
'
]
)
{
if
(
this
.
width
<
img
.
width
)
{
this
.
width
=
img
[
'
width
'
]
;
this
.
width
=
img
.
width
;
}
}
if
(
this
.
height
<
img
[
'
height
'
]
)
{
if
(
this
.
height
<
img
.
height
)
{
this
.
height
=
img
[
'
height
'
]
;
this
.
height
=
img
.
height
;
}
}
}
}
...
@@ -1013,14 +1089,14 @@ export class MyAnimation extends MySprite {
...
@@ -1013,14 +1089,14 @@ export class MyAnimation extends MySprite {
}
}
showAllFrame
()
{
showAllFrame
()
{
for
(
let
i
=
0
;
i
<
this
.
frameArr
.
length
;
i
++
)
{
for
(
const
frame
of
this
.
frameArr
)
{
this
.
frameArr
[
i
]
.
alpha
=
1
;
frame
.
alpha
=
1
;
}
}
}
}
hideAllFrame
()
{
hideAllFrame
()
{
for
(
let
i
=
0
;
i
<
this
.
frameArr
.
length
;
i
++
)
{
for
(
const
frame
of
this
.
frameArr
)
{
this
.
frameArr
[
i
]
.
alpha
=
0
;
frame
.
alpha
=
0
;
}
}
}
}
...
@@ -1192,7 +1268,7 @@ export function endShow(item, s = 1) {
...
@@ -1192,7 +1268,7 @@ export function endShow(item, s = 1) {
const
tween
=
new
TWEEN
.
Tween
(
item
)
const
tween
=
new
TWEEN
.
Tween
(
item
)
.
to
({
alpha
:
1
,
scaleX
:
s
,
scaleY
:
s
},
800
)
.
to
({
alpha
:
1
,
scaleX
:
s
,
scaleY
:
s
},
800
)
.
easing
(
TWEEN
.
Easing
.
Elastic
.
Out
)
// Use an easing function to make the animation smooth.
.
easing
(
TWEEN
.
Easing
.
Elastic
.
Out
)
// Use an easing function to make the animation smooth.
.
onComplete
(
function
()
{
.
onComplete
(
()
=>
{
})
})
.
start
();
.
start
();
...
@@ -1200,14 +1276,14 @@ export function endShow(item, s = 1) {
...
@@ -1200,14 +1276,14 @@ export function endShow(item, s = 1) {
export
function
hideItem
(
item
,
time
=
0.8
,
callBack
=
null
,
easing
=
null
)
{
export
function
hideItem
(
item
,
time
=
0.8
,
callBack
=
null
,
easing
=
null
)
{
if
(
item
.
alpha
==
0
)
{
if
(
item
.
alpha
==
=
0
)
{
return
;
return
;
}
}
const
tween
=
new
TWEEN
.
Tween
(
item
)
const
tween
=
new
TWEEN
.
Tween
(
item
)
.
to
({
alpha
:
0
},
time
*
1000
)
.
to
({
alpha
:
0
},
time
*
1000
)
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
.
onComplete
(
function
()
{
.
onComplete
(
()
=>
{
if
(
callBack
)
{
if
(
callBack
)
{
callBack
();
callBack
();
}
}
...
@@ -1223,7 +1299,7 @@ export function hideItem(item, time = 0.8, callBack = null, easing = null) {
...
@@ -1223,7 +1299,7 @@ export function hideItem(item, time = 0.8, callBack = null, easing = null) {
export
function
showItem
(
item
,
time
=
0.8
,
callBack
=
null
,
easing
=
null
)
{
export
function
showItem
(
item
,
time
=
0.8
,
callBack
=
null
,
easing
=
null
)
{
if
(
item
.
alpha
==
1
)
{
if
(
item
.
alpha
==
=
1
)
{
if
(
callBack
)
{
if
(
callBack
)
{
callBack
();
callBack
();
}
}
...
@@ -1234,7 +1310,7 @@ export function showItem(item, time = 0.8, callBack = null, easing = null) {
...
@@ -1234,7 +1310,7 @@ export function showItem(item, time = 0.8, callBack = null, easing = null) {
const
tween
=
new
TWEEN
.
Tween
(
item
)
const
tween
=
new
TWEEN
.
Tween
(
item
)
.
to
({
alpha
:
1
},
time
*
1000
)
.
to
({
alpha
:
1
},
time
*
1000
)
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
.
onComplete
(
function
()
{
.
onComplete
(
()
=>
{
if
(
callBack
)
{
if
(
callBack
)
{
callBack
();
callBack
();
}
}
...
@@ -1252,9 +1328,9 @@ export function alphaItem(item, alpha, time = 0.8, callBack = null, easing = nul
...
@@ -1252,9 +1328,9 @@ export function alphaItem(item, alpha, time = 0.8, callBack = null, easing = nul
const
tween
=
new
TWEEN
.
Tween
(
item
)
const
tween
=
new
TWEEN
.
Tween
(
item
)
.
to
({
alpha
:
alpha
},
time
*
1000
)
.
to
({
alpha
},
time
*
1000
)
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
.
onComplete
(
function
()
{
.
onComplete
(
()
=>
{
if
(
callBack
)
{
if
(
callBack
)
{
callBack
();
callBack
();
}
}
...
@@ -1274,7 +1350,7 @@ export function showStar(item, time = 0.8, callBack = null, easing = null) {
...
@@ -1274,7 +1350,7 @@ export function showStar(item, time = 0.8, callBack = null, easing = null) {
const
tween
=
new
TWEEN
.
Tween
(
item
)
const
tween
=
new
TWEEN
.
Tween
(
item
)
.
to
({
alpha
:
1
,
scale
:
1
},
time
*
1000
)
.
to
({
alpha
:
1
,
scale
:
1
},
time
*
1000
)
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
// .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
.
onComplete
(
function
()
{
.
onComplete
(
()
=>
{
if
(
callBack
)
{
if
(
callBack
)
{
callBack
();
callBack
();
}
}
...
@@ -1330,22 +1406,22 @@ export function getAngleByPos(px, py, mx, my) {
...
@@ -1330,22 +1406,22 @@ export function getAngleByPos(px, py, mx, my) {
const
radina
=
Math
.
acos
(
cos
);
// 用反三角函数求弧度
const
radina
=
Math
.
acos
(
cos
);
// 用反三角函数求弧度
let
angle
=
Math
.
floor
(
180
/
(
Math
.
PI
/
radina
)
*
100
)
/
100
;
// 将弧度转换成角度
let
angle
=
Math
.
floor
(
180
/
(
Math
.
PI
/
radina
)
*
100
)
/
100
;
// 将弧度转换成角度
if
(
mx
>
px
&&
my
>
py
)
{
// 鼠标在第四象限
if
(
mx
>
px
&&
my
>
py
)
{
// 鼠标在第四象限
angle
=
180
-
angle
;
angle
=
180
-
angle
;
}
}
if
(
mx
===
px
&&
my
>
py
)
{
// 鼠标在y轴负方向上
if
(
mx
===
px
&&
my
>
py
)
{
// 鼠标在y轴负方向上
angle
=
180
;
angle
=
180
;
}
}
if
(
mx
>
px
&&
my
===
py
)
{
// 鼠标在x轴正方向上
if
(
mx
>
px
&&
my
===
py
)
{
// 鼠标在x轴正方向上
angle
=
90
;
angle
=
90
;
}
}
if
(
mx
<
px
&&
my
>
py
)
{
// 鼠标在第三象限
if
(
mx
<
px
&&
my
>
py
)
{
// 鼠标在第三象限
angle
=
180
+
angle
;
angle
=
180
+
angle
;
}
}
if
(
mx
<
px
&&
my
===
py
)
{
// 鼠标在x轴负方向
if
(
mx
<
px
&&
my
===
py
)
{
// 鼠标在x轴负方向
angle
=
270
;
angle
=
270
;
}
}
if
(
mx
<
px
&&
my
<
py
)
{
// 鼠标在第二象限
if
(
mx
<
px
&&
my
<
py
)
{
// 鼠标在第二象限
angle
=
360
-
angle
;
angle
=
360
-
angle
;
}
}
...
@@ -1357,7 +1433,7 @@ export function getAngleByPos(px, py, mx, my) {
...
@@ -1357,7 +1433,7 @@ export function getAngleByPos(px, py, mx, my) {
export
function
removeItemFromArr
(
arr
,
item
)
{
export
function
removeItemFromArr
(
arr
,
item
)
{
const
index
=
arr
.
indexOf
(
item
);
const
index
=
arr
.
indexOf
(
item
);
if
(
index
!=
-
1
)
{
if
(
index
!=
=
-
1
)
{
arr
.
splice
(
index
,
1
);
arr
.
splice
(
index
,
1
);
}
}
}
}
...
@@ -1367,7 +1443,7 @@ export function removeItemFromArr(arr, item) {
...
@@ -1367,7 +1443,7 @@ export function removeItemFromArr(arr, item) {
export
function
circleMove
(
item
,
x0
,
y0
,
time
=
2
,
addR
=
360
,
xPer
=
1
,
yPer
=
1
,
callBack
=
null
,
easing
=
null
){
export
function
circleMove
(
item
,
x0
,
y0
,
time
=
2
,
addR
=
360
,
xPer
=
1
,
yPer
=
1
,
callBack
=
null
,
easing
=
null
)
{
const
r
=
getPosDistance
(
item
.
x
,
item
.
y
,
x0
,
y0
);
const
r
=
getPosDistance
(
item
.
x
,
item
.
y
,
x0
,
y0
);
let
a
=
getAngleByPos
(
item
.
x
,
item
.
y
,
x0
,
y0
);
let
a
=
getAngleByPos
(
item
.
x
,
item
.
y
,
x0
,
y0
);
...
@@ -1432,18 +1508,20 @@ export function formatTime(fmt, date) {
...
@@ -1432,18 +1508,20 @@ export function formatTime(fmt, date) {
// "yyyy-MM-dd HH:mm:ss";
// "yyyy-MM-dd HH:mm:ss";
const
o
=
{
const
o
=
{
"
M+
"
:
date
.
getMonth
()
+
1
,
// 月份
'
M+
'
:
date
.
getMonth
()
+
1
,
// 月份
"
d+
"
:
date
.
getDate
(),
// 日
'
d+
'
:
date
.
getDate
(),
// 日
"
h+
"
:
date
.
getHours
(),
// 小时
'
h+
'
:
date
.
getHours
(),
// 小时
"
m+
"
:
date
.
getMinutes
(),
// 分
'
m+
'
:
date
.
getMinutes
(),
// 分
"
s+
"
:
date
.
getSeconds
(),
// 秒
'
s+
'
:
date
.
getSeconds
(),
// 秒
"
q+
"
:
Math
.
floor
((
date
.
getMonth
()
+
3
)
/
3
),
// 季度
'
q+
'
:
Math
.
floor
((
date
.
getMonth
()
+
3
)
/
3
),
// 季度
"
S
"
:
date
.
getMilliseconds
()
// 毫秒
S
:
date
.
getMilliseconds
()
// 毫秒
};
};
if
(
/
(
y+
)
/
.
test
(
fmt
))
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
date
.
getFullYear
()
+
""
).
substr
(
4
-
RegExp
.
$1
.
length
));
if
(
/
(
y+
)
/
.
test
(
fmt
))
{
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
date
.
getFullYear
()
+
''
).
substr
(
4
-
RegExp
.
$1
.
length
));
}
for
(
var
k
in
o
)
for
(
const
k
in
o
)
{
if
(
new
RegExp
(
"
(
"
+
k
+
"
)
"
).
test
(
fmt
))
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
RegExp
.
$1
.
length
==
1
)
if
(
new
RegExp
(
'
(
'
+
k
+
'
)
'
).
test
(
fmt
))
{
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
RegExp
.
$1
.
length
===
1
)
?
(
o
[
k
])
:
((
"
00
"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
)));
?
(
o
[
k
])
:
((
'
00
'
+
o
[
k
]).
substr
((
''
+
o
[
k
]).
length
)));
}
}
return
fmt
;
return
fmt
;
}
}
...
...
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