pubgv3/assets/scripts/game/gamerevive2.js
zhuguoqing ff550d5d6a init
2022-05-22 10:32:02 +08:00

74 lines
2.0 KiB
JavaScript

// Learn cc.Class:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
var playerData = require("playerData")
cc.Class({
extends: cc.Component,
properties: {
lb_time:{
default: null,
type: cc.Label,
},
pro:{
default: null,
type: cc.ProgressBar,
},
},
// LIFE-CYCLE CALLBACKS:
onLoad(){
cc.Notifier.on('playerrevive', this, this.playerrevive.bind(this));
},
onDestroy(){
cc.Notifier.off('playerrevive', this);
},
playerrevive(){
this.time = 0
},
setdata(t){
this.totaltime = t
this.time = t;
this.lb_time.node.color = cc.Color.WHITE
this.lb_time.string = this.time;
this.pro.progress = 1
},
update (dt) {
if (this.rev_flag) {
return;
}
if(this.time>=0){
this.time-=dt
if(this.time<=0){
this.time=0
this.node.active = false
playerData.bannerflag = true
}else{
var num = Math.ceil(this.time)
if(num<=3){
this.lb_time.node.color = cc.Color.RED
}
this.lb_time.string = num
}
this.pro.progress = this.time / this.totaltime
}
},
});