It looks like a timer’s value keeps updating even after it’s been paused? I expected it to not change after :pause() was called, and to only begin incrementing again after calling :start()
I put together a minimal repro - if you press A and check the console output you will see the value incrementing normally, but if you press A again, wait for a couple of seconds, and press A once more, you will notice the value has jumped as though the timer was never paused.
import 'CoreLibs/timer'
local timer = playdate.timer.new(12000, 1, 1000)
timer:pause()
timer.updateCallback = function ()
print('timer update', timer.value)
end
timer.timerEndedCallback = function ()
print('timer end', timer.value)
end
local isPlaying = false
function playdate:AButtonDown()
if isPlaying then
timer:pause()
print('paused timer')
isPlaying = false
else
timer:start()
print('started timer')
isPlaying = true
end
end
function playdate.update()
playdate.timer.updateTimers()
end
For now, editing CoreLibs/timer.lua so that the :start() function sets the timer’s _lastTime value back to nil seems to work:
function playdate.timer:start()
self._lastTime = nil
self.paused = false
end
I ran into this bug again on SDK 1.13.0, and it's been so long I had forgotten about it and spent a few minutes very confused in the debugger . Is a fix in the roadmap?
I'm working on a game and I have this issue but I am not 100% sure how to edit the core libs timer file. Can you expand on how to update the core libs timer file so the timers work correctly? I looked for other threads but I cannot find anything. Appreciate any help, I have come a long way on my project just from looking at threads like this. Timers are the bane of my existence right now so I would love to get this right, I have the pause code written perfectly but my timer always resets!