Page 1 of 1
Detecting Clicks?
Posted: Wed Jul 05, 2023 8:59 pm
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
!
Re: Detecting Clicks?
Posted: Thu Jul 06, 2023 5:08 am
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
!
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)