// 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 Freeze extends cc.Component { static _instance: any; time: number = 60; @property(cc.Material) freeze: cc.Material = null; // mapInfo: number[][] = []; onLoad () { } start () { } init(time,type){ if(time) this.time = time; this.node.getChildByName("time").active = true; NumberToImage.numberToImageNodes(this.time,40,25,"ice_",this.node.getChildByName("time"),false); // this.node.getChildByName("time").getComponent(cc.Label).string = this.time.toString(); } reduce(number){ this.time -= number; if(this.time <= 0) this.time = 0 NumberToImage.numberToImageNodes(this.time,40,25,"ice_",this.node.getChildByName("time"),false); // this.node.getChildByName("time").getComponent(cc.Label).string = this.time.toString(); if(this.time <= 0){ this.node.getChildByName("bingkuai").active = true; const skeleton = this.node.getChildByName("bingkuai").getComponent(sp.Skeleton); skeleton.setAnimation(1,"bingkuai",false); this.node.getChildByName("icon").active = true; this.node.getChildByName("time").active = false; cc.tween(this.node.getChildByName("icon")) .to(0.5, { opacity: 0 }) .start(); // this.node.getChildByName("icon").getComponent(cc.Sprite).setMaterial(0,this.freeze); // this.node.children.forEach(element => { // element.destroy(); // }); setTimeout(() => { this.node.parent.getComponent("Block").resetFreeze(); this.node.destroy(); this.node.removeFromParent(); }, 500); } } // update (dt) {} }