Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xiaoxiaole
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
wildfirecode13
xiaoxiaole
Commits
dfb92bdc
Commit
dfb92bdc
authored
Oct 22, 2019
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
1b766b54
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
378 additions
and
86 deletions
+378
-86
MainScene.ts
egret/src/mainScene/MainScene.ts
+219
-74
Tool.ts
egret/src/something/Tool.ts
+55
-11
EleMaskAni.ts
egret/src/something/anis/EleMaskAni.ts
+51
-0
RectMask.ts
egret/src/something/class/RectMask.ts
+22
-0
RecoverName.ts
egret/src/something/enum/RecoverName.ts
+3
-0
FallAniData.ts
egret/src/something/interface/FallAniData.ts
+27
-0
PathData.ts
egret/src/something/interface/PathData.ts
+1
-1
No files found.
egret/src/mainScene/MainScene.ts
View file @
dfb92bdc
This diff is collapsed.
Click to expand it.
egret/src/something/Tool.ts
View file @
dfb92bdc
...
...
@@ -6,8 +6,11 @@ import { PassType } from "./enum/PassType";
import
{
EffectType
}
from
"./enum/EffectType"
;
import
{
Pool
}
from
"./Pool"
;
import
{
RecoverName
}
from
"./enum/RecoverName"
;
import
{
RectMask
}
from
"./class/RectMask"
;
import
{
FallType
}
from
"./interface/FallAniData"
;
export
class
Tool
{
public
static
latDeltaTime
=
100
;
public
static
rowNum
=
9
;
public
static
colNum
=
9
;
/**
...
...
@@ -715,37 +718,58 @@ export class Tool {
return
arr
}
/**
* 找一个格子,最终掉落点
,
* @param lattice 能掉落的格子
* 找一个格子,最终掉落点
,所有的index吧
* @param lattice 能掉落的格子
,格子上肯定有元素,并且能掉落
* @param empty
* @param lattices
* @return
返回空格数组中的索引
* @return
所有中间点吧数据
*/
public
static
findBottom
(
lattice
:
Lattice
,
emptys
:
number
[],
lattices
:
Lattice
[]):
number
{
let
indexDown
,
lat
;
public
static
findBottom
(
lattice
:
Lattice
,
emptys
:
number
[],
lattices
:
Lattice
[]):
{
index
:
number
,
type
:
FallType
}[]
{
let
indexDown
:
number
,
lat
:
Lattice
;
let
connects
:
{
index
:
number
,
type
:
FallType
}[]
=
[];
let
isThrough
:
boolean
=
false
;
//找下面的
if
(
lattice
.
down
!=
null
)
{
indexDown
=
lattice
.
down
;
isThrough
=
true
;
}
else
{
indexDown
=
lattice
.
index
+
this
.
colNum
;
}
let
lastEmptyIndex
:
number
;
//下方有格子,并且再this.empty中
let
emptyIndex
:
number
=
emptys
.
indexOf
(
indexDown
);
//只要还在里面就一直找下,直到
while
(
emptyIndex
>
-
1
)
{
if
(
isThrough
)
connects
.
push
({
index
:
indexDown
,
type
:
FallType
.
THROUGH
});
//记录下上一个满足的
lastEmptyIndex
=
emptyIndex
;
//下面格子变成lat
lat
=
lattices
[
indexDown
];
if
(
lat
.
down
!=
null
)
{
//如果上次是false的,就结束加入
if
(
!
isThrough
)
connects
.
push
({
index
:
indexDown
,
type
:
FallType
.
STRIGHT
});
isThrough
=
true
indexDown
=
lat
.
down
;
}
else
{
isThrough
=
false
indexDown
=
lat
.
index
+
this
.
colNum
;
}
emptyIndex
=
emptys
.
indexOf
(
indexDown
);
}
if
(
lastEmptyIndex
!=
undefined
)
{
return
lastEmptyIndex
//说明已经加过,然后down无空格,直线已加
if
(
isThrough
)
{
return
connects
}
//直线未加
else
{
connects
.
push
({
index
:
emptys
[
lastEmptyIndex
],
type
:
FallType
.
STRIGHT
})
return
connects
}
}
else
{
return
null
}
...
...
@@ -758,11 +782,18 @@ export class Tool {
var
index
=
Tool
.
rcToIndex
(
n
,
m
);
let
lat
=
lattices
[
index
];
if
(
Tool
.
judgeFall
(
lat
))
{
var
emptyIndex
=
Tool
.
findBottom
(
lat
,
emptys
,
lattices
);
var
downIndex
=
emptys
[
emptyIndex
];
if
(
emptyIndex
!=
null
)
{
if
(
(
downIndex
-
index
)
/
Tool
.
colNum
>
1
)
{
var
indexs
=
Tool
.
findBottom
(
lat
,
emptys
,
lattices
);
if
(
indexs
!=
null
)
{
//超过一步,肯定true
if
(
indexs
.
length
>
1
)
{
return
true
;
}
else
{
var
downIndex
:
number
=
indexs
[
0
].
index
;
var
type
:
FallType
=
indexs
[
0
].
type
;
//直线的
if
(
type
==
FallType
.
STRIGHT
&&
(
downIndex
-
index
)
/
Tool
.
colNum
>
1
)
{
return
true
;
}
}
}
}
else
{
...
...
@@ -773,7 +804,12 @@ export class Tool {
var
downIndex
=
index
;
while
(
emptys
.
indexOf
(
downIndex
)
>
-
1
)
{
arr
.
push
(
downIndex
);
downIndex
+=
Tool
.
colNum
;
if
(
lat
.
down
!=
null
)
{
downIndex
=
lat
.
down
;
}
else
{
downIndex
=
lat
.
index
+
this
.
colNum
;
}
lat
=
lattices
[
downIndex
];
}
if
(
arr
.
length
>
1
)
return
true
}
...
...
@@ -830,6 +866,14 @@ export class Tool {
}
return
obj
}
/**
* 获得矩形遮罩
*/
public
static
getRectMask
():
RectMask
{
let
rect
:
RectMask
=
Pool
.
takeOut
(
RecoverName
.
RECT_MASK
);
if
(
!
rect
)
rect
=
new
RectMask
()
return
rect
;
}
/**
* 返回个十百等,0是个位
...
...
egret/src/something/anis/EleMaskAni.ts
0 → 100644
View file @
dfb92bdc
import
{
Tool
}
from
"../Tool"
;
import
{
ElementType
}
from
"../enum/ElementType"
;
import
{
EffectType
}
from
"../enum/EffectType"
;
import
{
Element
}
from
"../class/Element"
;
import
{
Pool
}
from
"../Pool"
;
import
{
RecoverName
}
from
"../enum/RecoverName"
;
/**
* 矩形遮罩的元素动画
* @param eleC
* @param p
* @param con
* @param callback
*/
export
function
EleMaskAni
(
eleC
:
Element
,
p
:
number
[],
wait
:
number
,
con
:
egret
.
DisplayObjectContainer
,
isUp
:
boolean
=
false
,
callback
?:
Function
)
{
let
ele
=
Tool
.
getElement
(
eleC
.
type
);
ele
.
effectType
=
eleC
.
effectType
;
ele
.
x
=
p
[
0
];
ele
.
y
=
p
[
1
]
-
Tool
.
height
*
(
isUp
?
0
:
1
);
let
mask
=
Tool
.
getRectMask
();
mask
.
x
=
p
[
0
];
mask
.
y
=
p
[
1
];
ele
.
mask
=
mask
;
con
.
addChild
(
mask
);
egret
.
Tween
.
get
(
ele
)
.
wait
(
wait
)
.
call
(()
=>
{
con
.
addChild
(
ele
);
})
.
to
({
x
:
p
[
0
],
y
:
p
[
1
]
+
Tool
.
height
*
(
isUp
?
1
:
0
)
},
Tool
.
latDeltaTime
)
.
call
(()
=>
{
//回收元素
con
.
removeChild
(
ele
);
Pool
.
recover
(
RecoverName
.
ELEMENT
,
ele
);
//回收遮罩
ele
.
mask
=
null
;
mask
.
recover
();
//回调
callback
&&
callback
();
})
}
\ No newline at end of file
egret/src/something/class/RectMask.ts
0 → 100644
View file @
dfb92bdc
import
{
Tool
}
from
"../Tool"
;
import
{
Pool
}
from
"../Pool"
;
import
{
RecoverName
}
from
"../enum/RecoverName"
;
/**
* 元素出现及消失用到的矩形遮罩
*/
export
class
RectMask
extends
egret
.
Shape
{
constructor
()
{
super
();
this
.
graphics
.
beginFill
(
0xffffff
);
this
.
graphics
.
beginFill
(
0xff0000
,
1
);
this
.
graphics
.
drawRect
(
-
Tool
.
width
/
2
,
-
Tool
.
height
/
2
,
Tool
.
width
,
Tool
.
height
)
this
.
graphics
.
endFill
();
}
recover
()
{
if
(
this
.
parent
)
{
this
.
parent
.
removeChild
(
this
);
Pool
.
recover
(
RecoverName
.
RECT_MASK
,
this
);
}
}
}
\ No newline at end of file
egret/src/something/enum/RecoverName.ts
View file @
dfb92bdc
...
...
@@ -42,4 +42,7 @@ export enum RecoverName {
STEP_ANI
=
"StepAni"
,
JELLYDIS_ANI
=
"JellyDisAni"
,
EGGBROKEN_ANI
=
"EggBrokenAni"
,
//方形遮罩
RECT_MASK
=
"RectMask"
}
\ No newline at end of file
egret/src/something/interface/FallAniData.ts
0 → 100644
View file @
dfb92bdc
import
{
Element
}
from
"../class/Element"
;
/**
* 掉落动画数据
*/
export
interface
FallAniData
{
/**
* 掉落元素,设为null的时候要生成,并且通过遮罩,生成动画
*/
ele
:
Element
;
/**
* 等待时间,一般用于一个生成口有多个元素排列着的情况
* ele为null才需要wait
*/
wait
?:
number
;
/**
* 起点、中间点及终点的索引,穿过记录下格子,不可能为空
* 索引加类型
*/
indexs
:
{
index
:
number
,
type
:
FallType
}[]
// indexs:number[];
}
export
enum
FallType
{
STRIGHT
=
0
,
THROUGH
,
}
\ No newline at end of file
egret/src/something/interface/PathData.ts
View file @
dfb92bdc
/**
* 路径数据
* 路径数据
,废弃不用
*/
export
interface
PathData
{
/**
...
...
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