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
44d16abf
Commit
44d16abf
authored
May 22, 2023
by
Friends233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
填入方块
parent
172bc42b
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
121 additions
and
7 deletions
+121
-7
Game.fire
assets/Scenes/Game.fire
+10
-4
GameConfig.ts
assets/Script/Config/GameConfig.ts
+3
-1
GameScene.ts
assets/Script/GameScene.ts
+2
-0
block.ts
assets/Script/block.ts
+10
-2
propPool.ts
assets/Script/propPool.ts
+26
-0
propPool.ts.meta
assets/Script/propPool.ts.meta
+10
-0
block.anim
assets/resources/ani/block.anim
+16
-0
block.anim.meta
assets/resources/ani/block.anim.meta
+6
-0
matrix.png
assets/resources/images/matrix.png
+0
-0
matrix.png.meta
assets/resources/images/matrix.png.meta
+38
-0
No files found.
assets/Scenes/Game.fire
View file @
44d16abf
...
...
@@ -981,9 +981,9 @@
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r":
0
,
"g":
47
,
"b":
47
,
"r":
255
,
"g":
255
,
"b":
255
,
"a": 255
},
"_contentSize": {
...
...
@@ -1041,7 +1041,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "
a23235d1-15db-4b95-8439-a2e005bfff91
"
"__uuid__": "
64d79601-a932-4f3b-9641-70a789ca43eb
"
},
"_type": 0,
"_sizeMode": 0,
...
...
@@ -1843,6 +1843,9 @@
"__id__": 36
},
"_enabled": true,
"defaultBlock": {
"__uuid__": "00d2b9dc-0261-4f19-854e-b24e4a40a5a6"
},
"_id": "a4SYzpDRhLKbA1M1ndEoSa"
},
{
...
...
@@ -1950,6 +1953,7 @@
"__id__": 39
},
"_enabled": true,
"defaultBlock": null,
"_id": "63a0+R6PtPZJEYz5VGpUZF"
},
{
...
...
@@ -2057,6 +2061,7 @@
"__id__": 42
},
"_enabled": true,
"defaultBlock": null,
"_id": "4ecYOoNDZMP5mT5LqBUEhP"
},
{
...
...
@@ -2164,6 +2169,7 @@
"__id__": 45
},
"_enabled": true,
"defaultBlock": null,
"_id": "015qvGmjFBvZ4YMP/Y7Qz3"
},
{
...
...
assets/Script/Config/GameConfig.ts
View file @
44d16abf
...
...
@@ -17,5 +17,7 @@ export const Config = {
/** 块矩阵最大行 */
maxRow
:
10
,
/** 块矩阵最大列 */
maxCol
:
10
maxCol
:
10
,
/** 填入方块颜色,小方块颜色 */
miniBlockColor
:
'#58D9B3'
}
\ No newline at end of file
assets/Script/GameScene.ts
View file @
44d16abf
...
...
@@ -2,6 +2,7 @@ import Svga from "./Components/Svga/Svga";
import
{
SvgaEvent
}
from
"./Components/Svga/SvgaEvent"
;
import
{
CUSTOM_EVENT
,
Config
,
GameColors
}
from
"./Config/GameConfig"
;
import
exportEvent
from
"./exportEvent"
;
import
propPool
from
"./propPool"
;
import
{
getProbability
,
getRandomArrayElements
,
loadGameResources
,
numToChinese
,
randomNum
,
getUrlParam
}
from
"./utils"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -31,6 +32,7 @@ export default class GameScene extends cc.Component {
start
()
{
this
.
blockMatrix
=
cc
.
find
(
'blockMatrix'
,
this
.
node
)
cc
.
propPool
=
propPool
this
.
setDefaultBlock
()
this
.
addNodeEvent
()
}
...
...
assets/Script/block.ts
View file @
44d16abf
...
...
@@ -5,10 +5,15 @@
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
import
{
Config
}
from
"./Config/GameConfig"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
Block
extends
cc
.
Component
{
/** 默认底色块 */
@
property
(
cc
.
Prefab
)
defaultBlock
:
cc
.
Prefab
=
null
isMove
=
false
...
...
@@ -35,8 +40,11 @@ export default class Block extends cc.Component {
const
matrix
=
cc
.
find
(
'blockMatrix'
,
this
.
node
.
parent
.
parent
)
const
{
targetPos
,
targetNode
}
=
this
.
posFindBlock
(
targetNodeWorldPos
)
this
.
isMove
=
false
const
p
=
this
.
node
.
convertToNodeSpaceAR
(
targetPos
)
this
.
node
.
setPosition
(
cc
.
v2
(
p
.
x
+
this
.
node
.
x
,
p
.
y
+
this
.
node
.
y
))
targetNode
.
color
=
cc
.
color
(
Config
.
miniBlockColor
)
// const targetWorldPos = this.node.convertToNodeSpaceAR(targetPos)
// const blockPos = cc.v2(targetWorldPos.x + this.node.x, targetWorldPos.y + this.node.y)
// const blockTemp = cc.propPool.isEmpyt ? cc.instantiate(this.defaultBlock) : cc.propPool.pop()
// blockTemp.setPosition(blockPos)
}
/**
...
...
assets/Script/propPool.ts
0 → 100644
View file @
44d16abf
class
PropPool
{
/** 道具回收池 */
public
pool
=
[]
private
_isEmpyt
=
true
/** 是否为空 */
public
get
isEmpyt
()
{
return
!
this
.
pool
?.
length
;
}
/** 增加道具回收池道具 */
public
push
(
prop
)
{
prop
.
active
=
false
this
.
pool
.
push
(
prop
)
}
/** 二次利用道具 */
public
pop
()
{
if
(
this
.
pool
.
length
===
0
)
return
null
const
prop
=
this
.
pool
.
pop
()
prop
.
active
=
true
return
prop
}
}
export
default
new
PropPool
()
\ No newline at end of file
assets/Script/propPool.ts.meta
0 → 100644
View file @
44d16abf
{
"ver": "1.1.0",
"uuid": "4aa71ca2-9aeb-4f5b-a9be-fc18763579fd",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/resources/ani/block.anim
0 → 100644
View file @
44d16abf
{
"__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/block.anim.meta
0 → 100644
View file @
44d16abf
{
"ver": "2.1.2",
"uuid": "bf38991e-566d-4e1e-ad67-dd4f834bff23",
"importer": "animation-clip",
"subMetas": {}
}
\ No newline at end of file
assets/resources/images/matrix.png
0 → 100644
View file @
44d16abf
23.1 KB
assets/resources/images/matrix.png.meta
0 → 100644
View file @
44d16abf
{
"ver": "2.3.7",
"uuid": "26470550-9b89-4263-926c-90b12a412838",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 602,
"height": 601,
"platformSettings": {},
"subMetas": {
"matrix": {
"ver": "1.0.6",
"uuid": "64d79601-a932-4f3b-9641-70a789ca43eb",
"importer": "sprite-frame",
"rawTextureUuid": "26470550-9b89-4263-926c-90b12a412838",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 602,
"height": 601,
"rawWidth": 602,
"rawHeight": 601,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
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