Detecting Clicks?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
-Bangester-
Prole
Posts: 21
Joined: Tue Mar 07, 2023 11:01 pm

Detecting Clicks?

Post by -Bangester- »

Hello everyone! I'm currently facing an issue how do I detect if i click on an image ??? if that's not possible, how about a body ??

CONCLUSION: how do i detect if i clicked on a pic or body? like what code ?? please show me the code that can for example if I click on a square that square disappears or if I click on a image that image disappears. thank you in :awesome: !
User avatar
darkfrei
Party member
Posts: 1186
Joined: Sat Feb 08, 2020 11:09 pm

Re: Detecting Clicks?

Post by darkfrei »

-Bangester- wrote: Wed Jul 05, 2023 8:59 pm Hello everyone! I'm currently facing an issue how do I detect if i click on an image ??? if that's not possible, how about a body ??

CONCLUSION: how do i detect if i clicked on a pic or body? like what code ?? please show me the code that can for example if I click on a square that square disappears or if I click on a image that image disappears. thank you in :awesome: !
Always something like:

Code: Select all

for iObj, obj in ipairs (Objects) do
	if mustBeDeleted (obj) then
		obj.valid = false -- just ignore it or remove it later
	end
end
or

Code: Select all

for iObj = #Objects, 1, -1 do -- backwards
	local obj = Objects[iObj]
	if mustBeDeleted (obj) then
		table.remove (Objects, iObj)
	end
end
To detect clicks and drag-n-drops: viewtopic.php?p=254122 (small example how to move rectangles by clicking)
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 9 guests