cb/assets/Script/prop/ButtonWall.ts
2026-04-28 15:29:06 +08:00

63 lines
1.9 KiB
TypeScript

// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import MapConroler from "../Map";
import NumberToImage from "../NumberToImage";
const { ccclass, property } = cc._decorator;
@ccclass
export default class ButtonWall extends cc.Component {
static _instance: any;
time: number = 60;
@property(cc.SpriteAtlas)
UI: cc.SpriteAtlas = null;
posX: any;
posY: any;
color: number = -1;
// mapInfo: number[][] = [];
onLoad() {
}
start() {
}
setSpriteFrame(color, open, length) {
if (this.node.getChildByName("heng").active == true) {
let up = this.node.getChildByName("heng").getChildByName("up");
let upName = "heng" + length + "_" + "color" + color + "_up";
up.getComponent(cc.Sprite).spriteFrame = this.UI.getSpriteFrame(upName);
let down = this.node.getChildByName("heng").getChildByName("down");
let downName = "heng" + length + "_" + "color" + color + "_down";
down.getComponent(cc.Sprite).spriteFrame = this.UI.getSpriteFrame(downName);
}
else if (this.node.getChildByName("shu").active == true) {
let left = this.node.getChildByName("shu").getChildByName("left");
let leftName = "shu" + length + "_" + "color" + color + "_left";
left.getComponent(cc.Sprite).spriteFrame = this.UI.getSpriteFrame(leftName);
let right = this.node.getChildByName("shu").getChildByName("right");
let rightName = "shu" + length + "_" + "color" + color + "_right";
right.getComponent(cc.Sprite).spriteFrame = this.UI.getSpriteFrame(rightName);
}
}
// update (dt) {}
}