Commit 780f929d authored by zjz1994's avatar zjz1994

倒计时显示

parent 763e5968
......@@ -2,10 +2,12 @@ export default class CountDown extends egret.EventDispatcher {
_txt: eui.Label;
_timer: egret.Timer;
_func;
constructor(txt?,func?) {
_addspace:boolean = false;
constructor(txt?,func?,addspace=false) {
super();
this._txt = txt;
this._func = func;
this._addspace = addspace;
this._timer = new egret.Timer(1000);
this._timer.addEventListener(egret.TimerEvent.TIMER, this.onTimer, this);
this._timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.onTimerComplete, this);
......@@ -25,7 +27,12 @@ export default class CountDown extends egret.EventDispatcher {
const h = Math.floor( left / 3600);
const m = Math.floor ( (left % 3600) / 60 );
const s = left % 3600 % 60;
this._txt.text = `${this.getNumber(h)} : ${this.getNumber(m)} : ${this.getNumber(s)}`;
if(this._addspace){
this._txt.text = `${this.getNumber(h)} : ${this.getNumber(m)} : ${this.getNumber(s)}`;
}else{
this._txt.text = `${this.getNumber(h)}:${this.getNumber(m)}:${this.getNumber(s)}`;
}
if(this._func) {
this._txt.text = this._func(this._txt.text);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment