Someone else posted this code originally on the forum so full credit needs to be given to them. Sorry if any typos, doing this from memory.
function mousepressed(x, y, button)
-- left mouse button clicked
if love.mouse_left then
-- check if click was on a body on screen
if intersects(x, y, body:getX(), body:getY(), 32) -- assuming 32 is the radius of the circle body you're checking against
-- do something
end
end
end
function intersects(x1, y1, x2, y2, r)
local dx = x1 - x2
local dy = y1 - y2
return (dx*dx+dy*dy) < (r*r)
end
first problem
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests