1
下面的倒計時時鐘從秒,分鐘,日,月,年,我怎麼會增加毫秒到這個?倒計時如何添加毫秒
local secondsLeft = 3.154e + 7
-- one year
local clockText = display.newText("00.00:00:00:00", display.contentCenterX, 80, "font1.ttf", 60)
sceneGroup:insert(bg)
sceneGroup:insert(title)
sceneGroup:insert(summary)
sceneGroup:insert(clockText)
sceneGroup:insert(clockText)
local SECONDS_IN_HOUR = 60 * 60
local SECONDS_IN_DAY = 24 * SECONDS_IN_HOUR
local SECONDS_IN_MONTH = 30 * SECONDS_IN_DAY
-- assuming an average of 30 days per month
local SECONDS_IN_YEAR = 365 * SECONDS_IN_DAY
local function updateTime()
-- decrement the number of seconds
secondsLeft = secondsLeft - 1
-- time is tracked in seconds. We need to convert it to minutes and seconds
local years = math.floor((secondsLeft/SECONDS_IN_YEAR) % 365)
local months = math.floor((secondsLeft/SECONDS_IN_MONTH) % 12)
local days = math.floor((secondsLeft/SECONDS_IN_DAY) % 30)
local hours = math.floor((secondsLeft/SECONDS_IN_HOUR) % 24)
local minutes = math.floor((secondsLeft/60) % 60)
local seconds = secondsLeft % 60
-- make it a string using string format.
local timeDisplay = string.format("%02d·%02d·%02d·%02d·%02d·%02d", years, months, days, hours, minutes, seconds)
clockText.text = timeDisplay
end
local countDownTimer = timer.performWithDelay(100, updateTime, secondsLeft)
嘗試'運行:的addEventListener( 「enterFrame事件」,函數(事件),印刷(event.time)結束)'[文檔這裏( https://docs.coronalabs.com/api/event/enterFrame/time.html) – Albert