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
Hide 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 @@
...
@@ -3,34 +3,41 @@
*/
*/
import
{
IAnimation
}
from
"./IAnimation"
;
import
{
IAnimation
}
from
"./IAnimation"
;
export
class
Wave
implements
IAnimation
{
export
function
round
(
h
:
number
,
t
:
number
):
any
{
static
round
:
Function
=
function
(
h
:
number
,
t
:
number
):
any
{
return
{
x
:
Math
.
cos
(
t
)
*
h
,
y
:
Math
.
sin
(
t
)
*
h
};
return
{
x
:
Math
.
cos
(
t
)
*
h
,
y
:
Math
.
sin
(
t
)
*
h
};
}
};
static
cos
:
Function
=
function
(
h
:
number
,
t
:
number
):
any
{
return
{
x
:
Math
.
cos
(
t
)
*
h
,
y
:
0
};
};
static
sin
:
Function
=
function
(
h
:
number
,
t
:
number
):
any
{
h
=
h
||
1
;
return
{
x
:
0
,
y
:
Math
.
sin
(
t
)
*
h
};
};
static
rotate
:
Function
=
function
(
t
:
number
):
any
{
return
{
r
:
360
*
t
/
Math
.
PI
/
2
};
};
static
shake
:
Function
=
function
(
angle
:
number
,
count
:
number
,
t
:
number
):
any
{
return
{
r
:
Math
.
sin
(
t
*
count
)
*
angle
};
};
static
breath
:
Function
=
function
(
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
{
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
{
return
{
alpha
:
(
Math
.
sin
(
t
)
+
1
)
*
0.5
+
base
};
};
export
function
cos
(
h
:
number
,
t
:
number
):
any
{
return
{
x
:
Math
.
cos
(
t
)
*
h
,
y
:
0
};
}
export
function
sin
(
h
:
number
,
t
:
number
):
any
{
h
=
h
||
1
;
return
{
x
:
0
,
y
:
Math
.
sin
(
t
)
*
h
};
}
export
function
rotate
(
t
:
number
):
any
{
return
{
r
:
360
*
t
/
Math
.
PI
/
2
};
}
export
function
shake
(
angle
:
number
,
count
:
number
,
t
:
number
):
any
{
return
{
r
:
Math
.
sin
(
t
*
count
)
*
angle
};
}
export
function
breath
(
scale
:
number
,
t
:
number
):
any
{
return
{
sx
:
Math
.
sin
(
t
)
*
scale
+
1
,
sy
:
-
Math
.
sin
(
t
+
Math
.
PI
/
4
)
*
scale
+
1
};
}
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
};
}
export
function
fade
(
base
,
t
:
number
):
any
{
return
{
alpha
:
(
Math
.
sin
(
t
)
+
1
)
*
0.5
+
base
};
}
export
class
Wave
implements
IAnimation
{
_tween
:
egret
.
Tween
;
_tween
:
egret
.
Tween
;
target
:
any
;
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.
...
@@ -16,7 +16,7 @@ export function callNet(url: string, params: any = null, method: string = egret.
resolve
(
request
.
response
);
resolve
(
request
.
response
);
},
this
);
},
this
);
request
.
addEventListener
(
egret
.
IOErrorEvent
.
IO_ERROR
,
function
(
event
:
egret
.
Event
):
void
{
request
.
addEventListener
(
egret
.
IOErrorEvent
.
IO_ERROR
,
function
(
event
:
egret
.
Event
):
void
{
reject
(
'request error.'
);
reject
(
new
Error
(
'request error.'
)
);
},
this
);
},
this
);
request
.
open
(
finalUrl
,
method
);
request
.
open
(
finalUrl
,
method
);
...
...
src/tools/MathUtils.ts
View file @
9d80174a
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* @returns {number}
* @returns {number}
*/
*/
export
function
distancePoint
(
p1
:
any
,
p2
:
any
):
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) {
...
@@ -38,6 +38,9 @@ export function centerPoint(p1: any, p2: any) {
* @returns {number}
* @returns {number}
*/
*/
export
function
radian
(
p1
:
any
,
p2
:
any
):
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
);
return
Math
.
atan2
(
p2
.
y
-
p1
.
y
,
p2
.
x
-
p1
.
x
);
}
}
...
@@ -48,7 +51,11 @@ export function radian(p1: any, p2: any): number {
...
@@ -48,7 +51,11 @@ export function radian(p1: any, p2: any): number {
* @returns {number}
* @returns {number}
*/
*/
export
function
angle
(
p1
:
any
,
p2
:
any
):
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 {
...
@@ -91,7 +98,7 @@ export function makeRandomByRange(value: number, range: number): number {
export
function
makeRandomIntArr
(
len
:
number
,
max
:
number
,
min
:
number
=
0
):
number
[]
{
export
function
makeRandomIntArr
(
len
:
number
,
max
:
number
,
min
:
number
=
0
):
number
[]
{
let
target
:
number
[]
=
[];
let
target
:
number
[]
=
[];
for
(
let
i
:
number
=
0
;
i
<
len
;
i
++
)
{
for
(
let
i
:
number
=
0
;
i
<
len
;
i
++
)
{
target
.
push
(
this
.
makeRandomInt
(
max
));
target
.
push
(
makeRandomInt
(
max
));
}
}
return
target
;
return
target
;
...
@@ -120,8 +127,8 @@ export function makeOrderIntArray(to: number, from: number = 0, step: number = 1
...
@@ -120,8 +127,8 @@ export function makeOrderIntArray(to: number, from: number = 0, step: number = 1
*/
*/
export
function
mixArray
(
arr
:
any
):
Array
<
any
>
{
export
function
mixArray
(
arr
:
any
):
Array
<
any
>
{
for
(
let
i
:
number
=
0
,
len
:
number
=
Math
.
round
(
arr
.
length
/
2
);
i
<
len
;
i
++
)
{
for
(
let
i
:
number
=
0
,
len
:
number
=
Math
.
round
(
arr
.
length
/
2
);
i
<
len
;
i
++
)
{
let
a
:
number
=
this
.
makeRandomInt
(
arr
.
length
);
let
a
:
number
=
makeRandomInt
(
arr
.
length
);
let
b
:
number
=
this
.
makeRandomInt
(
arr
.
length
);
let
b
:
number
=
makeRandomInt
(
arr
.
length
);
let
temp
=
arr
[
a
];
let
temp
=
arr
[
a
];
arr
[
a
]
=
arr
[
b
];
arr
[
a
]
=
arr
[
b
];
arr
[
b
]
=
temp
;
arr
[
b
]
=
temp
;
...
@@ -141,8 +148,8 @@ export function mixArray2(arr: Array<Array<any>>): Array<Array<any>> {
...
@@ -141,8 +148,8 @@ export function mixArray2(arr: Array<Array<any>>): Array<Array<any>> {
let
pos0
:
number
[];
let
pos0
:
number
[];
let
pos1
:
number
[];
let
pos1
:
number
[];
for
(
let
i
:
number
=
0
,
len
:
number
=
Math
.
round
(
cH
*
cV
/
2
);
i
<
len
;
i
++
)
{
for
(
let
i
:
number
=
0
,
len
:
number
=
Math
.
round
(
cH
*
cV
/
2
);
i
<
len
;
i
++
)
{
pos0
=
[
this
.
makeRandomInt
(
cH
),
this
.
makeRandomInt
(
cV
)];
pos0
=
[
makeRandomInt
(
cH
),
makeRandomInt
(
cV
)];
pos1
=
[
this
.
makeRandomInt
(
cH
),
this
.
makeRandomInt
(
cV
)];
pos1
=
[
makeRandomInt
(
cH
),
makeRandomInt
(
cV
)];
let
temp
=
arr
[
pos0
[
0
]][
pos0
[
1
]];
let
temp
=
arr
[
pos0
[
0
]][
pos0
[
1
]];
arr
[
pos0
[
0
]][
pos0
[
1
]]
=
arr
[
pos1
[
0
]][
pos1
[
1
]];
arr
[
pos0
[
0
]][
pos0
[
1
]]
=
arr
[
pos1
[
0
]][
pos1
[
1
]];
arr
[
pos1
[
0
]][
pos1
[
1
]]
=
temp
;
arr
[
pos1
[
0
]][
pos1
[
1
]]
=
temp
;
...
@@ -158,7 +165,7 @@ export function mixArray2(arr: Array<Array<any>>): Array<Array<any>> {
...
@@ -158,7 +165,7 @@ export function mixArray2(arr: Array<Array<any>>): Array<Array<any>> {
* @returns {*}
* @returns {*}
*/
*/
export
function
getRandomFromArray
(
arr
:
any
,
del
=
false
):
any
{
export
function
getRandomFromArray
(
arr
:
any
,
del
=
false
):
any
{
let
index
=
this
.
makeRandomInt
(
arr
.
length
);
let
index
=
makeRandomInt
(
arr
.
length
);
let
item
=
arr
[
index
];
let
item
=
arr
[
index
];
if
(
del
)
{
if
(
del
)
{
arr
.
splice
(
index
,
1
);
arr
.
splice
(
index
,
1
);
...
@@ -303,7 +310,7 @@ export function split(total, count) {
...
@@ -303,7 +310,7 @@ export function split(total, count) {
result
[
i
]
=
0
;
result
[
i
]
=
0
;
}
}
for
(
let
i
=
0
;
i
<
total
;
i
++
)
{
for
(
let
i
=
0
;
i
<
total
;
i
++
)
{
result
[
this
.
makeRandomInt
(
count
)]
++
;
result
[
makeRandomInt
(
count
)]
++
;
}
}
return
result
;
return
result
;
}
}
...
@@ -363,7 +370,7 @@ export function intersectToPolygon(points: any[], intersect: any[]) {
...
@@ -363,7 +370,7 @@ export function intersectToPolygon(points: any[], intersect: any[]) {
dd
=
points
[
i
+
1
];
dd
=
points
[
i
+
1
];
}
}
if
(
this
.
intersectToIntersect
(
aa
,
bb
,
cc
,
dd
))
{
if
(
intersectToIntersect
(
aa
,
bb
,
cc
,
dd
))
{
result
=
true
;
result
=
true
;
break
;
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