Page 1 of 1

Intersect or Within

Posted: Fri Jul 04, 2014 6:33 pm
by richmond62
I was working my way through this: https://sites.google.com/a/pgcps.org/livecode/

and thinking how good it was, when I cam across the stuff about 'intersect' here: https://sites.google.com/a/pgcps.org/li ... ng-objects

Now, to be completely and utterly honest, I had never come across intersect at all, and have always used 'within' for drag-and-drop things.

So; naturally enough, I whipped up a little stack to do a compare-and-contrast exercise.

INTERSECT allows overlaps, while WITHIN is very strict.

The problem with INTERSECT is particularly awkward when one's draggable object intersects 2 objects that are mentioned in its script.

This is a bit awkward to explain, so I am uploading a stack to illustrate this.
The image "panda" uses INTERSECT, and the image "adnap" uses WiTHIN (crack open the scripts to see how they work):

http://andregarzia.on-rev.com/richmond/ ... vecode.zip

Re: Intersect or Within

Posted: Fri Jul 04, 2014 8:08 pm
by sefrojones
In your example, I think "within" is the proper function to use. I have used "intersect" for collision detection. Consider this example:

The panda is controlled by the arrow keys, and the user is moving around the screen trying to collect coins. You want the coin to disappear/make a noise as soon as the panda comes into contact with the coin. This is where I would use the intersect function, as you want the action to happen when the panda is intersecting with the coin and not when it is fully within it's rect.


Hope this made some sense.

--Sefro

Re: Intersect or Within

Posted: Fri Jul 04, 2014 8:13 pm
by richmond62
Yes; it makes sense. Thanks, Sefro.

Re: Intersect or Within

Posted: Sun Jul 06, 2014 2:24 pm
by [-hh]
..........

Re: Intersect or Within

Posted: Sun Jul 06, 2014 6:33 pm
by richmond62
Unless you tell it otherwise INTERSECT will signal when the boundaries of an object, whether they
be transparent or not, are overlapped.