how can I make the rotation of an object change depending on the distance to the joytstick?
local personaje = display.newImage("survivor.png", ax, ay) personaje:scale(0.2,0.2) physics.addBody(personaje) local joy = display.newCircle(ax +100, ay + 200, 50) joy:setFillColor(0,0.2,0.8, 0.5) local function mover(event) if event.phase == "began" then personaje:setLinearVelocity( (event.x - joy.x), (event.y - joy.y)) elseif event.phase == "moved" then personaje:setLinearVelocity( (event.x - joy.x), (event.y - joy.y) ) personaje.rotation = (event.target.x - event.x) \*5 -- I tried this out but it doesn't work print((event.target.x - event.x)\*5) elseif ( event.phase == "ended" or event.phase == "cancelled" ) then personaje:setLinearVelocity(0, 0) end end joy:addEventListener("touch", mover)
how can I make the rotation of an object change depending on the distance to the joytstick