Instead of putting the circle back to the previous position you have to move it to the point inside the circle that is closest to the new position. This is exactly what you also do for the mouse control. For example you could do this:Ulydev wrote:When you're in-game, try to make a smooth circle around the edges of the grey/black zone like you would do with mouse controls. It's actually impossible, is there any way to make it smoother ?
Code: Select all
local distance = math.sqrt(math.pow(480-objects.ball.x, 2)+math.pow(320-objects.ball.y, 2))
if distance > objects.zone.radius then
objects.ball.x = 480 + (objects.ball.x-480) * objects.zone.radius / distance
objects.ball.y = 320 + (objects.ball.y-320) * objects.zone.radius / distance
end