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
3086c8db
Commit
3086c8db
authored
May 22, 2023
by
Friends233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拖拽
parent
7cd7a7fe
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
2107 additions
and
266 deletions
+2107
-266
Game.fire
assets/Scenes/Game.fire
+2038
-174
GameConfig.ts
assets/Script/Config/GameConfig.ts
+4
-75
GameScene.ts
assets/Script/GameScene.ts
+23
-2
miniBlock.ts
assets/Script/miniBlock.ts
+18
-4
miniBlock.ts.meta
assets/Script/miniBlock.ts.meta
+1
-1
block.prefab
assets/resources/prefab/block.prefab
+22
-9
block.prefab.meta
assets/resources/prefab/block.prefab.meta
+1
-1
No files found.
assets/Scenes/Game.fire
View file @
3086c8db
This diff is collapsed.
Click to expand it.
assets/Script/Config/GameConfig.ts
View file @
3086c8db
export
const
CUSTOM_EVENT
=
{
/** 爪子动画结束的回调 */
CLIP_ANI_END
:
'CLIP_ANI_END'
,
/** 爪子碰撞 */
CLIP_COLLISION
:
'CLIP_COLLISION'
,
/** 游戏结束 */
GAME_OVER
:
'GAME_OVER'
,
/** 下一关 */
...
...
@@ -16,77 +12,10 @@ export const CUSTOM_EVENT = {
/** 销毁游戏场景 */
GAME_DESTROY
:
'GAME_DESTROY'
}
/** 游戏进度颜色 */
export
const
GameColors
=
[
[
'#EC5F33'
,
'#E52800'
,
'#CA1D00'
],
[
'#FF9400'
,
'#FF6C00'
,
'#EC5F33'
,
'#E52800'
,
'#CA1D00'
],
[
'#FFD34A'
,
'#FFC300'
,
'#FFB637'
,
'#FF9400'
,
'#FF6C00'
,
'#EC5F33'
,
'#E52800'
,
'#CA1D00'
]
]
export
const
Config
=
{
/** 爪子能伸出去的长度 */
maxLong
:
644
,
/** 摇晃速度 */
rotationSpeed
:
1
,
/** 爪子伸出去的速度 */
playSpeed
:
350
,
/** 普通道具移动速度 */
normalPropSpeed
:
250
,
/** 高级道具移动速度 */
bestPropSpeed
:
500
,
/** 每轮生成加分道具数量 */
bestPropsNum
:
3
,
/** 普通道具每种最多生成数量 */
propsNum
:
2
,
/** 每关的游戏时间 */
countDowns
:
[
30
,
30
,
30
],
/** 关卡信息 */
LevelInfo
:
[
{
level
:
1
,
/** 目标数量 */
num
:
10
,
/** 倒计时 */
cds
:
30
,
},
{
level
:
1
,
/** 目标数量 */
num
:
5
,
/** 倒计时 */
cds
:
30
,
},
{
level
:
1
,
/** 目标数量 */
num
:
8
,
/** 倒计时 */
cds
:
30
,
}
],
/** 进度默认颜色 */
defaultColor
:
"#FF6C00"
,
/** 道具分布图 4*3 */
propsMap
:
[
[
1
,
0
,
0
,
1
,
1
,
1
,
1
,
0
,
1
,
1
,
1
,
1
],
[
1
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
0
,
1
,
1
]
]
/** 块矩阵最大行 */
maxRow
:
10
,
/** 块矩阵最大列 */
maxCol
:
10
}
\ No newline at end of file
assets/Script/GameScene.ts
View file @
3086c8db
...
...
@@ -9,9 +9,16 @@ const { ccclass, property } = cc._decorator;
@
ccclass
export
default
class
GameScene
extends
cc
.
Component
{
/** 默认底色块 */
@
property
(
cc
.
Prefab
)
defaultBlock
:
cc
.
Prefab
=
null
/** 游戏配置 */
gameConfig
=
{
...
Config
}
/** 方块矩阵 */
blockMatrix
:
cc
.
Node
=
null
protected
onLoad
():
void
{
...
...
@@ -23,9 +30,23 @@ export default class GameScene extends cc.Component {
}
start
()
{
this
.
blockMatrix
=
cc
.
find
(
'blockMatrix'
,
this
.
node
)
this
.
setDefaultBlock
()
this
.
addNodeEvent
()
}
/** 设置默认方块底色块 */
setDefaultBlock
()
{
const
{
maxRow
,
maxCol
}
=
this
.
gameConfig
const
parent
=
this
.
blockMatrix
for
(
let
i
=
0
;
i
<
maxRow
;
i
++
)
{
for
(
let
j
=
0
;
j
<
maxCol
;
j
++
)
{
const
block
=
cc
.
instantiate
(
this
.
defaultBlock
)
block
.
setParent
(
parent
)
}
}
}
/** 添加节点的事件 */
addNodeEvent
()
{
// cc.game.on(cc.game.EVENT_HIDE, () => {
...
...
@@ -124,12 +145,12 @@ export default class GameScene extends cc.Component {
/** 下一关 */
nextLevel
()
{
}
/** 刷新舞台道具 */
refreshStageProps
()
{
}
update
(
dt
:
number
):
void
{
...
...
assets/Script/
blockItem
.ts
→
assets/Script/
miniBlock
.ts
View file @
3086c8db
// Learn TypeScript:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
BlockItem
extends
cc
.
Component
{
export
default
class
NewClass
extends
cc
.
Component
{
isMove
=
false
viewWidth
=
0
viewHeight
=
0
/** 方块矩阵外层容器 */
blockMatrix
:
cc
.
Node
=
null
start
()
{
this
.
viewHeight
=
cc
.
view
.
getVisibleSize
().
height
this
.
viewWidth
=
cc
.
view
.
getVisibleSize
().
width
this
.
addNodeEvent
()
const
matrix
=
cc
.
find
(
'blockMatrix'
,
this
.
node
.
parent
)
const
matrix
=
this
.
blockMatrix
=
cc
.
find
(
'blockMatrix'
,
this
.
node
.
parent
)
const
node
=
matrix
.
children
[
0
]
const
k
=
node
.
convertToWorldSpaceAR
(
node
.
getPosition
())
console
.
log
(
'start'
,
k
.
x
,
k
.
y
)
...
...
@@ -31,16 +42,19 @@ export default class BlockItem extends cc.Component {
addNodeEvent
()
{
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
()
=>
{
console
.
log
(
'TOUCH_START'
)
this
.
isMove
=
true
this
.
node
.
scale
=
1.57
},
this
)
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
()
=>
{
console
.
log
(
'TOUCH_END'
)
this
.
setBlockMatrixAll
(
this
.
node
.
getPosition
())
},
this
)
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
(
e
:
cc
.
Event
.
EventTouch
)
=>
{
const
allBlock
=
this
.
node
.
children
const
matrix
=
cc
.
find
(
'blockMatrix'
,
this
.
node
.
parent
)
const
matrix
=
this
.
blockMatrix
const
node
=
allBlock
[
0
]
const
blockPos
=
node
.
convertToWorldSpaceAR
(
node
.
getPosition
())
...
...
@@ -50,7 +64,7 @@ export default class BlockItem extends cc.Component {
if
(
this
.
isMove
)
{
const
pos
:
cc
.
Vec2
=
e
.
getPreviousLocation
()
const
viewW
=
this
.
viewWidth
,
viewH
=
this
.
viewHeight
this
.
node
.
setPosition
(
pos
.
x
-
(
viewW
/
2
),
pos
.
y
-
(
812
-
(
1624
-
viewH
)
/
2
))
}
},
this
)
...
...
assets/Script/
blockItem
.ts.meta
→
assets/Script/
miniBlock
.ts.meta
View file @
3086c8db
{
"ver": "1.1.0",
"uuid": "
d3a58978-56d5-45f1-b300-f7e269a2a93a
",
"uuid": "
005cb974-4dad-45ce-acb8-fb0f1da60d28
",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
...
...
assets/resources/prefab/
procItem
.prefab
→
assets/resources/prefab/
block
.prefab
View file @
3086c8db
...
...
@@ -13,7 +13,7 @@
},
{
"__type__": "cc.Node",
"_name": "
procItem
",
"_name": "
block
",
"_objFlags": 0,
"_parent": null,
"_children": [],
...
...
@@ -21,23 +21,26 @@
"_components": [
{
"__id__": 2
},
{
"__id__": 3
}
],
"_prefab": {
"__id__":
3
"__id__":
4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r":
229
,
"g": 1
23
,
"b": 1
23
,
"r":
143
,
"g": 1
86
,
"b": 1
86
,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width":
39
,
"height":
41
"width":
58
,
"height":
58
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -48,8 +51,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
20.5
,
0,
-270
,
27
0,
0,
0,
0,
...
...
@@ -105,6 +108,16 @@
"_atlas": null,
"_id": ""
},
{
"__type__": "b1207cbMWhNVLKTFVfAq/t2",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
...
...
assets/resources/prefab/
procItem
.prefab.meta
→
assets/resources/prefab/
block
.prefab.meta
View file @
3086c8db
{
"ver": "1.3.2",
"uuid": "
579f375a-1df7-440f-aded-3c14d59e021d
",
"uuid": "
00d2b9dc-0261-4f19-854e-b24e4a40a5a6
",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
...
...
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