Can't update `frame` of a paused Animation Loop

If I pause an animation loop, the frame value doesn't get updated, even if I pause the loop after setting frame.

Expectation:
I expect this to pause on frame 5 of the loop:

loop.frame = 5
loop.paused = true
loop:draw(0,0)

Actual result:
The loop pauses on whatever the value of frame was at the beginning of the update loop.

Info
I looked at animation.lua. It seems setting frame only updates the animation time offset. The currentFrame internal value that actually fetches the image frame gets set based on that time offset in updateLoopAnimation . But updateLoopAnimation gets skipped if the loop is paused. So currentFrame will never get updated even if pausing after setting frame.

Workaround
Since updateLoopAnimation gets called from the frame accessor, I can force currentFrame to get set by accessing frame before pausing. This works as expected (the loop pauses on frame 5):

loop.frame = 5
local f = loop.frame -- force animation.loop to set currentFrame
loop.paused = true
loop:draw(0,0)
1 Like

It looks like this issue got fixed a while back (SDK version 1.4 I believe), but I neglected to update this issue - let me know if you're still seeing unexpected behavior!