This content has been marked as final.
Show 3 replies

1. Re: hitTest but not for boundaries
tonyhigham Feb 28, 2007 6:51 AM (in response to MajiDfn)If you just need to hittest circles, you can do so by checking the distance between the centers of the circles. For instance, assuming you have two circle mc's with center registration, named ball1 and ball2...
//First, find the x and y distances between the centers
var distX:Number = Math.abs(ball1._x  ball2._x)
var distY:Number = Math.abs(ball1._y  ball2._y)
//Use the x and y distances to find the acual distance
var distT:Number = Math.sqrt(Math.pow(distX,2)+Math.pow(distY,2))
//Compare the total distance to 2*the radius
if(distT <= ball1.width){
trace("CONTACT")
} else {
trace("NO CONTACT")
}
This can be used with multiple mc's with a simple 'for' loop. Keep in mind that you may need to adjust the conditional statement to compensate for errors due to the fact that your mc's move by more than 1 pixel per frame. 
2. Re: hitTest but not for boundaries
MajiDfn Mar 3, 2007 12:54 AM (in response to tonyhigham)Dear tonyhigham
thanks for your quick response.
It's very useful if all the movieclips are exactly circle.
But what about the situation which you have movieclips with nongeometric shaped ... like a car or something similar.
any idea would help me alot
regards
MajiD 
3. Re: hitTest but not for boundaries
kglad Mar 3, 2007 8:05 AM (in response to MajiDfn)see grant skinner's collision detection:
http://www.gskinner.com/blog/archives/2005/10/source_code_sha.html