Commit 44d16abf authored by Friends233's avatar Friends233

填入方块

parent 172bc42b
......@@ -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"
},
{
......
......@@ -17,5 +17,7 @@ export const Config = {
/** 块矩阵最大行 */
maxRow: 10,
/** 块矩阵最大列 */
maxCol: 10
maxCol: 10,
/** 填入方块颜色,小方块颜色 */
miniBlockColor:'#58D9B3'
}
\ No newline at end of file
......@@ -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()
}
......
......@@ -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)
}
/**
......
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
{
"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
{
"__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
{
"ver": "2.1.2",
"uuid": "bf38991e-566d-4e1e-ad67-dd4f834bff23",
"importer": "animation-clip",
"subMetas": {}
}
\ No newline at end of file
{
"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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment