I have no idea if Cocos provides a function for this, but the math is really very simple.
You take the two center points of the circles and get the distance between them using the standard distance formula. float distance = sqrt(pow((x2-x1), 2) + pow((y2-y1), 2) and check if this is less than the sum of the radius of the two circles that you are checking.
BOOL checkCircleCollision(CGPoint center1, float radius1, CGPoint center2, float radius2) { float distance = sqrt(pow((center2.x-center1.x), 2) + pow((center2.y-center1.y), 2); return distance < (radius1 + radius2); } BOOL optimized_CheckCircleCollision(CGPoint center1, float radius1, CGPoint center2, float radius2) { float a = center2.x - center1.x; float b = center2.y - center1.y; float c = radius1 + radius2; float distanceSqrd = (a * a) + (b * b); return distanceSqrd < (c * c); }
source share