0
votes

I'm having a difficult time figuring out having objects with multiple bounds for a drag-able object. HitTest isn't working because when dragging fast, the object will overlap before HitTest fires. I was wondering if there was a more efficient way for figuring out this interaction.

I'm going to try to store each rectangle x,y,width,height, and then loop through those, to figure out if the object has touched and stop the player from being draggable in that direction.

Here's the example as a drawing.

1
If you only need collision on a standard DisplayList, there is absolutely NO NEED to use Box2D, which by the way is a physics engine that also has collision detection built in. If you only want to test collision against bounds of these objects you can use draggable.bounds.intersects(blueStuff.bounds). - Gio
Thanks Gio, but how would I read which site it intersects at? - Tom
I'd have a Vector or an Array of those intersectable sites and check them in a for loop in Event.ENTER_FRAME handler, which would start listening after starting a drag and would stop after finishing the drag. - Gio

1 Answers

0
votes

Because you are trying to detect collisions happening at high speeds, you need to use some form of swept-polygon collision detection. Sampling collision at only one time between the previous and the last frame will always have a chance of failing.

Check out this brief explanation of Swept Collision detection: http://howlingmoonsoftware.com/wordpress/?p=300

Or just do a search for "swept collision detection"

If you are doing this in a game, you might also find using a library like Box2D would be a worthy solution to the problem. In Box2D parlance what you want is continuous collision detection. http://www.box2d.org/manual.html