ActionScript: Detect collision between 2 circles

Posted on 11:02 AM

With the Pythagoeran theorem you can detect collision with 2 circles.

You just have to get the rays of 2 circles with the width property divided by 2.
Actually the width property returns the diameter of the circle. So, you can calculte the ray like this:

ray = diamter / 2
ray = circle.width / 2

Therefore if you get the distance between the 2 circles you can detect the collision like this:

if distance < ( circle1.width/2+ circle2.width/2 ) is true => Collision