Arc Animator / Draw Bug

,

Hello,

I use the Arc function in combination with Animator to make a sprite follow the path. At the same time I draw this path to see if the sprite follows the path correctly.

Here is a working code snippet:

import "CoreLibs/graphics"
import "CoreLibs/animator"
import "CoreLibs/sprites"
import "CoreLibs/timer"

local pd <const> = playdate
local gfx <const> = pd.graphics
local geo = pd.geometry
local ani = gfx.animator

local mapWidth = pd.display.getWidth()
local mapHeight = pd.display.getHeight()

local cornerRadius = 40
local p = geo.point.new(mapWidth/2, mapHeight/2)
local direction = true
local drawPath = {
    geo.arc.new(p.x - cornerRadius, p.y + cornerRadius, cornerRadius, 0, 90, direction),
}

local pathDuration = {10000}
local easings = {pd.easingFunctions.linear}
local newLvlAnimator = ani.new(pathDuration, drawPath, easings, 0)

local sprite = gfx.sprite.new(gfx.image.new(20, 20, gfx.kColorBlack))
sprite:add()
sprite:moveTo(100, 100)
sprite:setAnimator(newLvlAnimator, false, false)
function sprite:update()
    local x, y = newLvlAnimator:currentValue():unpack()
    sprite:moveTo(x,y)
end

function pd.update()

    gfx.sprite.update()
    gfx.drawArc(drawPath[1])

end

In my test, an arc with Animator and Draw works as intended. A problem, however, is a scenario when the arc runs counterclockwise. To test this you need to change direction to direction = false. The path is drawn correctly, but the animator runs wrong. The sprite then moves inverted.

Proper execution of Animator and Draw would be if counterclockwise/clockwise always refers to the specified arc segment. If I have a semicircle with Arc startValue: 0 and endValue:180, the specification of clockwise should only ever refer to how the animator should move clockwise or counterclockwise in this arc segment. Or am I misinterpreting something?

I'm using the latest LUA PlaydateSDK on Mac. Please let me know if this is an error and how I can fix it quickly.

This has been reported a few times. Not sure when the fix will be released.

Workaround:

2 Likes

Thanks for the quick reply.
The process works with the linked fix, but the duration is not correct. I'll have to wait for a fix.