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
Intersect or Within
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Intersect or Within
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
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
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Intersect or Within
..........
Last edited by [-hh] on Wed Aug 13, 2014 3:21 pm, edited 1 time in total.
shiftLock happens
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Intersect or Within
Unless you tell it otherwise INTERSECT will signal when the boundaries of an object, whether they
be transparent or not, are overlapped.
be transparent or not, are overlapped.