colorBlock/assets/Script/prop/Key.ts
YZ\249929363 4ca3daaa48 提交
2025-06-26 14:44:43 +08:00

49 lines
1.2 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";
const {ccclass, property} = cc._decorator;
@ccclass
export default class Key extends cc.Component {
static _instance: any;
time: number = 60;
// mapInfo: number[][] = [];
onLoad () {
}
start () {
}
init(time){
if(time) this.time = time;
this.node.getChildByName("time").active = true;
this.node.getChildByName("time").getComponent(cc.Label).string = this.time.toString();
this.schedule(this.updateTime, 1);
}
updateTime(){
this.time --;
this.node.getChildByName("time").getComponent(cc.Label).string = this.time.toString();
if(this.time <= 0){
this.unschedule(this.updateTime);
this.node.destroy();
MapConroler._instance.failLevel();
// this.node.destroy();
}
}
// update (dt) {}
}