drag-and-drop for matching exercises
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
drag-and-drop for matching exercises
I’m creating educational drag-and-drop activities, such as matching exercises. I have no problem as long as the drop locations are rectangles. The intersect function works fine for that. But when the drop location is not rectangular, neither the intersect function nor the within function works quite right. I want a match to occur if any visible portion of the objects overlap when dropped. But the intersect function returns true if the dragged object is within the rectangle surrounding the drop location. So two circles, for example, intersect if they are just nearby each other. Similarly, the within function returns true only if the center of one object is within the other. That requires two circles, for example, to overlap quite a lot, not just a little. Is there any function (or trick) that will detect if two non-rectangular objects (circles, polygons) overlap at all, but not when they are just close to each other? Thanks in advance!
Steve Alessi
Associate Professor
The University of Iowa
Associate Professor
The University of Iowa
Hi Steve,
you will need to have some collision detection handlers for that. If both objects are circles, that is rather trivial and can be calculated with some basic math. For polygons this is "a bit" more complicated. My add on library animationEngine has some sophisticated collision detection handlers, so you might want to download the demo version and see if that may help you.
All the best,
Malte
you will need to have some collision detection handlers for that. If both objects are circles, that is rather trivial and can be calculated with some basic math. For polygons this is "a bit" more complicated. My add on library animationEngine has some sophisticated collision detection handlers, so you might want to download the demo version and see if that may help you.
All the best,
Malte