cocos creator 倒计时code
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);