let countDownNode = this.viewNode.getChildByName('countDownNode').getComponent(cc.Label);
        countDownNode.string = '倒计时:00时05分00秒';
        let time = 300;
        countDownNode.schedule(function() {
            time--;
            let minute = parseInt(time / 60);
            let second = parseInt(time % 60);
            let hour = parseInt(minute / 60);
            let hour1 = hour > 60 ? hour % 24 : hour;
            let day = parseInt(hour / 24);
            minute = minute % 60;
            let timeStr = "";
            timeStr = hour <= 0 ? timeStr = "倒计时:" +
                // "00" + "天" +
                "00" + "时" +
                parseInt(minute / 10) + "" + minute % 10 + "分" +
                parseInt(second / 10) + "" + second % 10 + "秒" :
                timeStr = "倒计时:" +
                // parseInt(day / 10) + "" + day % 10 + "天" +
                parseInt(hour1 / 10) + "" + hour1 % 10 + "时" +
                parseInt(minute / 10) + "" + minute % 10 + "分" +
                parseInt(second / 10) + "" + second % 10 + "秒";
            countDownNode.string = timeStr;
        }, 1,time-1,0);    

 

相关文章:

  • 2021-12-26
  • 2021-05-15
  • 2022-12-23
  • 2021-08-17
  • 2021-08-24
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2021-12-25
  • 2022-12-23
  • 2021-08-22
  • 2021-10-01
  • 2021-06-23
  • 2021-11-07
相关资源
相似解决方案