PDA

View Full Version : Accurate Collision Detection



barge
January 4th, 2004, 03:16 PM
I was wondering how you get the collsion detection to be just what is in the MCs instead of a rectangularness of the movieClip.



Rectangularness? You know.

norie
January 4th, 2004, 04:31 PM
Originally posted by barge
Rectangularness? You know.
yea, also known as a movieclip's "bounding box." I know that the hit test can be more accurate with a single point, but between two objects, i don't think so. For a single point hit test, set the shapeFlag property to true.

barge
January 4th, 2004, 05:32 PM
huh?

So can i do anything? The bounding box has to be square?

norie
January 4th, 2004, 06:12 PM
Originally posted by barge
The bounding box has to be square?
yes

barge
January 4th, 2004, 06:14 PM
what?

norie
January 4th, 2004, 06:18 PM
yes, the bounding box, must be a square. No, there is nothing you can do (that i know of).

scotty
January 5th, 2004, 04:13 AM
Maybe you can use something like this
http://www.gotoandplay.it/_articles/2003/12/bezierCollision.php?PHPSESSID=e23cbc69b2889890c359 12b6544a60c4
http://www.gotoandplay.it/_articles/2003/09/collisions.php?PHPSESSID=e23cbc69b2889890c35912b65 44a60c4
?

scotty(-:

upuaut
January 6th, 2004, 04:05 AM
norie did explain, but it might need to be said a second time.

Setting the shape flag to TRUE will allow you to detect the colision of a single point with the actual shape of a movie clip.

ie.

attach this on a movie clip which is oddly shaped.



onClipEvent(mouseMove){
if(this.hitTest(_xmouse,_ymouse,true){
trace("I'm on the movie clip");
}
}

now if one had a circular movie clip, and was attempting to assertain if a point of that circlular clip was hitting an irregular object, that too could be done with a little math.

Two irregular objects, as far as I know, cannot be made to hitTest.

norie
January 6th, 2004, 12:15 PM
thank you for the elaboration upuaut :)