I am facing a problem yet again. So, I am making a game in corona. I want the object to move in a straight line to the touch coordinates. I know I can simple use the transition.to()
function but physics engine doesn't work properly during transitions. I wrote the following code but of course, the circle doesn't move in a straight path.
function controls(event)
if event.phase == "began" or event.phase == "moved" then
follow = true
touchX = event.x; touchY = event.y
end
if event.phase == "ended" then
follow = false
end
end
function playerMotion()
if follow == true then
if circle.y < touchY then
circle.y = circle.y + 1
elseif circle.y > touchY then
circle.y = circle.y - 1
end
if circle.x < touchX then
circle.x = circle.x + 1
elseif circle.x > touchX then
circle.x = circle.x - 1
end
end
end
Hope my question was clear enough.