Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alienlib
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
劳工
alienlib
Commits
9d80174a
Commit
9d80174a
authored
Sep 28, 2018
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
cff2d3ee
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
38 deletions
+63
-38
wave.ts
src/animation/wave.ts
+34
-27
TweenQueue.ts
src/egret/TweenQueue.ts
+11
-0
Ajax.ts
src/tools/Ajax.ts
+1
-1
MathUtils.ts
src/tools/MathUtils.ts
+17
-10
No files found.
src/animation/
W
ave.ts
→
src/animation/
w
ave.ts
View file @
9d80174a
...
...
@@ -3,34 +3,41 @@
*/
import
{
IAnimation
}
from
"./IAnimation"
;
export
class
Wave
implements
IAnimation
{
static
round
:
Function
=
function
(
h
:
number
,
t
:
number
):
any
{
export
function
round
(
h
:
number
,
t
:
number
):
any
{
return
{
x
:
Math
.
cos
(
t
)
*
h
,
y
:
Math
.
sin
(
t
)
*
h
};
};
static
cos
:
Function
=
function
(
h
:
number
,
t
:
number
):
any
{
}
export
function
cos
(
h
:
number
,
t
:
number
):
any
{
return
{
x
:
Math
.
cos
(
t
)
*
h
,
y
:
0
};
};
static
sin
:
Function
=
function
(
h
:
number
,
t
:
number
):
any
{
}
export
function
sin
(
h
:
number
,
t
:
number
):
any
{
h
=
h
||
1
;
return
{
x
:
0
,
y
:
Math
.
sin
(
t
)
*
h
};
};
static
rotate
:
Function
=
function
(
t
:
number
):
any
{
}
export
function
rotate
(
t
:
number
):
any
{
return
{
r
:
360
*
t
/
Math
.
PI
/
2
};
};
static
shake
:
Function
=
function
(
angle
:
number
,
count
:
number
,
t
:
number
):
any
{
}
export
function
shake
(
angle
:
number
,
count
:
number
,
t
:
number
):
any
{
return
{
r
:
Math
.
sin
(
t
*
count
)
*
angle
};
};
static
breath
:
Function
=
function
(
scale
:
number
,
t
:
number
):
any
{
}
export
function
breath
(
scale
:
number
,
t
:
number
):
any
{
return
{
sx
:
Math
.
sin
(
t
)
*
scale
+
1
,
sy
:
-
Math
.
sin
(
t
+
Math
.
PI
/
4
)
*
scale
+
1
};
};
static
zoom
:
Function
=
function
(
scale
:
number
,
t
:
number
):
any
{
}
export
function
zoom
(
scale
:
number
,
t
:
number
):
any
{
scale
=
scale
||
0.1
;
return
{
sx
:
Math
.
sin
(
t
)
*
scale
+
1
,
sy
:
Math
.
sin
(
t
)
*
scale
+
1
};
};
static
fade
:
Function
=
function
(
base
,
t
:
number
):
any
{
}
export
function
fade
(
base
,
t
:
number
):
any
{
return
{
alpha
:
(
Math
.
sin
(
t
)
+
1
)
*
0.5
+
base
};
};
}
export
class
Wave
implements
IAnimation
{
_tween
:
egret
.
Tween
;
target
:
any
;
...
...
src/egret/TweenQueue.ts
0 → 100644
View file @
9d80174a
/**
* Created by rockyl on 2018/9/26.
*
* 动画队列
*/
export
class
TweenQueue
{
push
(){
}
}
src/tools/Ajax.ts
View file @
9d80174a
...
...
@@ -16,7 +16,7 @@ export function callNet(url: string, params: any = null, method: string = egret.
resolve
(
request
.
response
);
},
this
);
request
.
addEventListener
(
egret
.
IOErrorEvent
.
IO_ERROR
,
function
(
event
:
egret
.
Event
):
void
{
reject
(
'request error.'
);
reject
(
new
Error
(
'request error.'
)
);
},
this
);
request
.
open
(
finalUrl
,
method
);
...
...
src/tools/MathUtils.ts
View file @
9d80174a
...
...
@@ -9,7 +9,7 @@
* @returns {number}
*/
export
function
distancePoint
(
p1
:
any
,
p2
:
any
):
number
{
return
this
.
distance
(
p1
.
x
,
p1
.
y
,
p2
.
x
,
p2
.
y
);
return
distance
(
p1
.
x
,
p1
.
y
,
p2
.
x
,
p2
.
y
);
}
/**
...
...
@@ -38,6 +38,9 @@ export function centerPoint(p1: any, p2: any) {
* @returns {number}
*/
export
function
radian
(
p1
:
any
,
p2
:
any
):
number
{
if
(
p2
.
y
==
p1
.
y
||
p2
.
x
==
p1
.
x
){
return
NaN
;
}
return
Math
.
atan2
(
p2
.
y
-
p1
.
y
,
p2
.
x
-
p1
.
x
);
}
...
...
@@ -48,7 +51,11 @@ export function radian(p1: any, p2: any): number {
* @returns {number}
*/
export
function
angle
(
p1
:
any
,
p2
:
any
):
number
{
return
this
.
radiusToAngle
(
this
.
radian
(
p1
,
p2
));
const
r
=
radian
(
p1
,
p2
);
if
(
isNaN
(
r
)){
return
r
;
}
return
radiusToAngle
(
r
);
}
/**
...
...
@@ -91,7 +98,7 @@ export function makeRandomByRange(value: number, range: number): number {
export
function
makeRandomIntArr
(
len
:
number
,
max
:
number
,
min
:
number
=
0
):
number
[]
{
let
target
:
number
[]
=
[];
for
(
let
i
:
number
=
0
;
i
<
len
;
i
++
)
{
target
.
push
(
this
.
makeRandomInt
(
max
));
target
.
push
(
makeRandomInt
(
max
));
}
return
target
;
...
...
@@ -120,8 +127,8 @@ export function makeOrderIntArray(to: number, from: number = 0, step: number = 1
*/
export
function
mixArray
(
arr
:
any
):
Array
<
any
>
{
for
(
let
i
:
number
=
0
,
len
:
number
=
Math
.
round
(
arr
.
length
/
2
);
i
<
len
;
i
++
)
{
let
a
:
number
=
this
.
makeRandomInt
(
arr
.
length
);
let
b
:
number
=
this
.
makeRandomInt
(
arr
.
length
);
let
a
:
number
=
makeRandomInt
(
arr
.
length
);
let
b
:
number
=
makeRandomInt
(
arr
.
length
);
let
temp
=
arr
[
a
];
arr
[
a
]
=
arr
[
b
];
arr
[
b
]
=
temp
;
...
...
@@ -141,8 +148,8 @@ export function mixArray2(arr: Array<Array<any>>): Array<Array<any>> {
let
pos0
:
number
[];
let
pos1
:
number
[];
for
(
let
i
:
number
=
0
,
len
:
number
=
Math
.
round
(
cH
*
cV
/
2
);
i
<
len
;
i
++
)
{
pos0
=
[
this
.
makeRandomInt
(
cH
),
this
.
makeRandomInt
(
cV
)];
pos1
=
[
this
.
makeRandomInt
(
cH
),
this
.
makeRandomInt
(
cV
)];
pos0
=
[
makeRandomInt
(
cH
),
makeRandomInt
(
cV
)];
pos1
=
[
makeRandomInt
(
cH
),
makeRandomInt
(
cV
)];
let
temp
=
arr
[
pos0
[
0
]][
pos0
[
1
]];
arr
[
pos0
[
0
]][
pos0
[
1
]]
=
arr
[
pos1
[
0
]][
pos1
[
1
]];
arr
[
pos1
[
0
]][
pos1
[
1
]]
=
temp
;
...
...
@@ -158,7 +165,7 @@ export function mixArray2(arr: Array<Array<any>>): Array<Array<any>> {
* @returns {*}
*/
export
function
getRandomFromArray
(
arr
:
any
,
del
=
false
):
any
{
let
index
=
this
.
makeRandomInt
(
arr
.
length
);
let
index
=
makeRandomInt
(
arr
.
length
);
let
item
=
arr
[
index
];
if
(
del
)
{
arr
.
splice
(
index
,
1
);
...
...
@@ -303,7 +310,7 @@ export function split(total, count) {
result
[
i
]
=
0
;
}
for
(
let
i
=
0
;
i
<
total
;
i
++
)
{
result
[
this
.
makeRandomInt
(
count
)]
++
;
result
[
makeRandomInt
(
count
)]
++
;
}
return
result
;
}
...
...
@@ -363,7 +370,7 @@ export function intersectToPolygon(points: any[], intersect: any[]) {
dd
=
points
[
i
+
1
];
}
if
(
this
.
intersectToIntersect
(
aa
,
bb
,
cc
,
dd
))
{
if
(
intersectToIntersect
(
aa
,
bb
,
cc
,
dd
))
{
result
=
true
;
break
;
}
...
...
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