Is timer:pause() broken, or am I just not using it correctly?

If I have a timer, for example...

myTimer = playdate.timer.new(1000, callback)
myTimer.repeats = true

And every frame I print(myTimer ._currentTime)

If I call myTimer:pause(), the value printed each frame stops increasing, but when I call myTimer:start(), the value printed will be some number far larger (depending on the amount of time I paused it for) than the length of the timer.

It value will count down until it is below the timer length, and then start cycling properly.

The real problem that it causes, (upon calling :start), is that it calls the callback once every frame until it has called it the number of times that it would have been called for the duration of the paused period.

Is this the intended behaviour?

I don't see how this would ever be useful. Surely if you pause something, you want it to resume from the point at which it was paused.

Am I missing something here? Or is this a bug?

Is there a proper way to actually pause a timer in the way that I would expect?

2 Likes

This is indeed a bug. Here’s a thread about it with a potential workaround.

I’ll lock this thread to keep the discussion in one place.