74 lines
2.0 KiB
TypeScript
74 lines
2.0 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 Boom 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;
|
|
NumberToImage.numberToImageNodes(this.time,20,8,"lock_",this.node.getChildByName("time"),false);
|
|
// this.node.getChildByName("time").getComponent(cc.Label).string = this.time.toString();
|
|
|
|
}
|
|
|
|
startBoom(){
|
|
this.schedule(this.updateTime, 1);
|
|
}
|
|
|
|
destroyBoom(){
|
|
this.unschedule(this.updateTime);
|
|
this.node.parent.getComponent("Block").resetFreeze();
|
|
this.node.destroy();
|
|
}
|
|
|
|
stopBoom(){
|
|
this.unschedule(this.updateTime);
|
|
}
|
|
|
|
|
|
|
|
updateTime(){
|
|
this.time --;
|
|
NumberToImage.numberToImageNodes(this.time,20,8,"lock_",this.node.getChildByName("time"),false);
|
|
if(this.time <= 0){
|
|
this.unschedule(this.updateTime);
|
|
this.node.getChildByName("zhandan").active = true;
|
|
this.node.getChildByName("bg").active = false;
|
|
const skeleton = this.node.getChildByName("zhandan").getComponent(sp.Skeleton);
|
|
skeleton.setAnimation(1,"eff",false);
|
|
// 监听动画完成事件
|
|
skeleton.setCompleteListener(() => {
|
|
// 动画播放完成后销毁节点
|
|
this.node.destroy();
|
|
});
|
|
MapConroler._instance.failLevel("boom");
|
|
// this.node.destroy();
|
|
}
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|