格式化
local seconds = 65
local day = math.floor(seconds / 86400)
seconds = math.fmod(seconds, 86400)
local hour = math.floor(seconds / 3600)
seconds = math.fmod(seconds, 3600)
local min = math.floor(seconds / 60)
local sec = math.fmod(seconds, 60)
if day > 0 then
return string.format("%02d:%02d:%02d:%02d", day, hour, min, sec)
else
return string.format("%02d:%02d:%02d", hour, min, sec);
end
倒数实现
self.maxMatchCd = 65
coroutine.start(function()
local currCd = self.maxMatchCd
self.forceStopMatchCD = false
while true do
coroutine.waitforseconds(1);
currCd = currCd -1
-- do somthing with param:currCd
if self.forceStopMatchCD then
break
end
end
end)
倒数暂停
self.forceStopMatchCD = true;