Intersect - button, group

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
antrax13
Posts: 39
Joined: Mon Jun 01, 2015 11:38 am

Intersect - button, group

Post by antrax13 » Tue Jun 16, 2015 11:18 am

Hi,

I have 1000 objects in group "Lines"

I need to find out what line (object) do I actually intersecting.

so I have

Code: Select all

if intersect(btn "player", group "Lines", "opaque pixels") then
answer "Collision"
end if
but I need

Code: Select all

if intersect(btn "player", group "Lines", "opaque pixels") then
answer "Collision with line XYZ in group Lines"
end if
How to get XYZ line in that group that I am actually intersecting?

Solution would be to check intersect for every single Line but there is too many lines.

antrax13
Posts: 39
Joined: Mon Jun 01, 2015 11:38 am

Re: Intersect - button, group

Post by antrax13 » Tue Jun 16, 2015 11:21 am

The reason why do I need to know that ID,Name is because I want to change the color of that Line where is the collision only.
I do not want to change the color of whole group "Lines"

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Intersect - button, group

Post by dunbarx » Tue Jun 16, 2015 2:15 pm

Hi.

You have 1000 line graphics in a group? Whew.

Anyway, simply loop through all those controls and check which ones intersect. It will not take much time...

Code: Select all

repeat with y = 1 to the number of graphics
get the owner of graphic y
if the owner of graphic y = it and intersect(btn "player",graphic y) then put graphic y & return after intersectList
end repeat
Why make a list? In other words, why not exit after the first intersect is found? Also, it is good practice to make all your lines in the group share a common name schema, like "line1, line2, etc. This would allow similar shenanigans to be implemented more readily.

Craig Newman

Post Reply