Page 1 of 1

Intersect - button, group

Posted: Tue Jun 16, 2015 11:18 am
by antrax13
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.

Re: Intersect - button, group

Posted: Tue Jun 16, 2015 11:21 am
by antrax13
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"

Re: Intersect - button, group

Posted: Tue Jun 16, 2015 2:15 pm
by dunbarx
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