Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Cocos-1010
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
等吃饭
Cocos-1010
Commits
73f1ab72
Commit
73f1ab72
authored
May 24, 2023
by
Friends233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消除动效
parent
32821f8b
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
282 additions
and
960 deletions
+282
-960
Game.fire
assets/Scenes/Game.fire
+160
-933
GameConfig.ts
assets/Script/Config/GameConfig.ts
+4
-2
GameScene.ts
assets/Script/GameScene.ts
+1
-1
block.ts
assets/Script/block.ts
+19
-3
blockManager.ts
assets/Script/blockManager.ts
+11
-4
utils.ts
assets/Script/utils.ts
+8
-0
block.anim
assets/resources/ani/block.anim
+0
-16
blockBoom.anim
assets/resources/ani/blockBoom.anim
+56
-0
blockBoom.anim.meta
assets/resources/ani/blockBoom.anim.meta
+0
-0
blockFab.prefab
assets/resources/prefab/blockFab.prefab
+23
-1
No files found.
assets/Scenes/Game.fire
View file @
73f1ab72
This diff is collapsed.
Click to expand it.
assets/Script/Config/GameConfig.ts
View file @
73f1ab72
...
...
@@ -19,9 +19,11 @@ export const Config = {
/** 块矩阵最大列 */
maxCol
:
10
,
/** 填入方块颜色,小方块颜色 */
miniBlockColor
:
'#58D9B3'
,
miniBlockColor
:
'#58D9B3'
,
/** 默认方块颜色,空白方块颜色 */
defaultColor
:
'#8FBABA'
,
defaultColor
:
'#8FBABA'
,
/** 每一个方块动画播放延时 ms*/
blockAniDelay
:
35
,
}
/** 方块状态 */
...
...
assets/Script/GameScene.ts
View file @
73f1ab72
...
...
@@ -41,7 +41,7 @@ export default class GameScene extends cc.Component {
const
parent
=
this
.
blockMatrix
const
setDefaultBlock
=
[]
for
(
let
i
=
0
;
i
<
maxCol
-
1
;
i
++
){
setDefaultBlock
.
push
(...
Array
(
6
).
fill
(
''
).
map
((
_
,
j
)
=>
j
+
i
*
maxRow
))
setDefaultBlock
.
push
(...
Array
(
9
).
fill
(
''
).
map
((
_
,
j
)
=>
j
+
i
*
maxRow
))
}
parent
.
removeAllChildren
()
for
(
let
i
=
0
;
i
<
maxRow
;
i
++
)
{
...
...
assets/Script/block.ts
View file @
73f1ab72
...
...
@@ -15,16 +15,31 @@ export default class Block extends cc.Component {
/** 方块状态 0空,1有方块填入 */
blockState
:
BLOCK_STATE
=
BLOCK_STATE
.
EMPTY
/** 动画 */
ani
:
cc
.
Animation
=
null
aniDuration
=
0
/** 方块动画播放速率 */
speed
=
0.9
// onLoad () {}
start
()
{
this
.
ani
=
this
.
node
.
getComponent
(
cc
.
Animation
)
const
animationState
=
this
.
ani
.
getAnimationState
(
'blockBoom'
)
this
.
aniDuration
=
animationState
.
duration
}
/** 播放清除动画 */
playClearAni
(
cb
)
{
this
.
changeBlockState
(
BLOCK_STATE
.
EMPTY
)
// propPool.push()
const
ani
=
this
.
ani
const
animationState
=
this
.
ani
.
getAnimationState
(
'blockBoom'
)
animationState
.
speed
=
this
.
speed
ani
.
once
(
'finished'
,()
=>
{
this
.
changeBlockState
(
BLOCK_STATE
.
EMPTY
)
cb
?.()
})
ani
.
play
()
}
/**
...
...
@@ -32,6 +47,7 @@ export default class Block extends cc.Component {
* @param type 0 清空,1 填入方块
*/
changeBlockState
(
type
:
BLOCK_STATE
)
{
this
.
node
.
scale
=
1
this
.
blockState
=
type
this
.
node
.
color
=
cc
.
color
(
type
===
BLOCK_STATE
.
NON_EMPTY
?
Config
.
miniBlockColor
:
Config
.
defaultColor
)
}
...
...
assets/Script/blockManager.ts
View file @
73f1ab72
...
...
@@ -7,6 +7,7 @@
import
{
BLOCK_STATE
,
Config
}
from
"./Config/GameConfig"
;
import
propPool
from
"./propPool"
;
import
{
waitTime
}
from
"./utils"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -68,7 +69,7 @@ export default class BlockManager extends cc.Component {
if
(
block
.
blockState
!==
BLOCK_STATE
.
NON_EMPTY
)
break
temp
.
push
(
block
)
if
(
temp
.
length
===
maxRow
)
{
eliminateBlocks
.
push
(
...
temp
)
eliminateBlocks
.
push
(
temp
)
}
}
}
...
...
@@ -81,7 +82,7 @@ export default class BlockManager extends cc.Component {
if
(
block
.
blockState
!==
BLOCK_STATE
.
NON_EMPTY
)
break
temp
.
push
(
block
)
if
(
temp
.
length
===
maxCol
)
{
eliminateBlocks
.
push
(
...
temp
)
eliminateBlocks
.
push
(
temp
)
}
}
}
...
...
@@ -92,9 +93,15 @@ export default class BlockManager extends cc.Component {
/** 清理矩阵块 */
clearMatrixBlock
(
eliminateBlocks
:
cc
.
Node
[])
{
if
(
eliminateBlocks
.
length
===
0
)
return
eliminateBlocks
.
forEach
(({
node
,
script
})
=>
{
const
recursionPlay
=
async
(
els
)
=>
{
if
(
els
.
length
===
0
)
return
const
{
script
}
=
els
.
pop
()
script
.
playClearAni
()
await
waitTime
(
Config
.
blockAniDelay
)
recursionPlay
(
els
)
}
eliminateBlocks
.
forEach
((
els
)
=>
{
recursionPlay
(
els
)
})
}
...
...
assets/Script/utils.ts
View file @
73f1ab72
/**
* 等待一段时间再执行
* @param {number} time 等待的时间ms
*/
export
function
waitTime
(
time
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
time
))
}
/**
* 十六进制颜色转rgb
* @param str
...
...
assets/resources/ani/block.anim
deleted
100644 → 0
View file @
32821f8b
{
"__type__": "cc.AnimationClip",
"_name": "block",
"_objFlags": 0,
"_native": "",
"_duration": 0,
"sample": 60,
"speed": 1,
"wrapMode": 1,
"curveData": {
"props": {
"color": []
}
},
"events": []
}
\ No newline at end of file
assets/resources/ani/blockBoom.anim
0 → 100644
View file @
73f1ab72
{
"__type__": "cc.AnimationClip",
"_name": "blockBoom",
"_objFlags": 0,
"_native": "",
"_duration": 0.16666666666666666,
"sample": 60,
"speed": 1,
"wrapMode": 1,
"curveData": {
"props": {
"color": [
{
"frame": 0,
"value": {
"__type__": "cc.Color",
"r": 222,
"g": 70,
"b": 91,
"a": 255
}
}
],
"scale": [
{
"frame": 0,
"value": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
}
},
{
"frame": 0.05,
"value": {
"__type__": "cc.Vec3",
"x": 1.15,
"y": 1.15,
"z": 1
}
},
{
"frame": 0.16666666666666666,
"value": {
"__type__": "cc.Vec3",
"x": 0.5,
"y": 0.5,
"z": 1
}
}
]
}
},
"events": []
}
\ No newline at end of file
assets/resources/ani/block.anim.meta
→
assets/resources/ani/block
Boom
.anim.meta
View file @
73f1ab72
File moved
assets/resources/prefab/blockFab.prefab
View file @
73f1ab72
...
...
@@ -24,10 +24,13 @@
},
{
"__id__": 3
},
{
"__id__": 4
}
],
"_prefab": {
"__id__":
4
"__id__":
5
},
"_opacity": 255,
"_color": {
...
...
@@ -118,6 +121,25 @@
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.Animation",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_defaultClip": {
"__uuid__": "bf38991e-566d-4e1e-ad67-dd4f834bff23"
},
"_clips": [
{
"__uuid__": "bf38991e-566d-4e1e-ad67-dd4f834bff23"
}
],
"playOnLoad": false,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
...
...
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