//倒计时
一 方法1 )
SetCountDownTime(){
let time=5;
let timeCallback=function(dt){
if(time && time>0){
time-=dt;
let _time=Math.ceil(time)
this.setTimeLabel(_time);
if(this.timeNodes&&this.timerNum_label){
this.timerNum_label.string=this._time;
}
}
}
this.schedule(timeCallback,1.0);
if(time<=0){
time=5;
}
}
二 方法2)
//倒计时
timer:number = 20;
Nexttim:number=0;
update (dt) {
this.timer-=dt;
this.Nexttim= Math.round(this.timer)
cc.find(‘coninue/txt’, this.node).getComponent(cc.Label).string = this.Nexttim.toString();
}
floor:下退 Math.floor(12.9999) = 12 ceil:上进 Math.ceil(12.1) = 13; round: 四舍五入 Math.round(12.5) = 13 Math.round(12.4) &