Skip to content

Instantly share code, notes, and snippets.

@numo16
Created December 12, 2012 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save numo16/4265129 to your computer and use it in GitHub Desktop.
Save numo16/4265129 to your computer and use it in GitHub Desktop.
Helper methods for Cocos2d-xna
public class CCUtils
{
public static CCRect CCRectIntersection(CCRect r1, CCRect r2)
{
CCRect intersection = new CCRect(Math.Max(CCRect.CCRectGetMinX(r1), CCRect.CCRectGetMinX(r2)), Math.Max(CCRect.CCRectGetMinY(r1), CCRect.CCRectGetMinY(r2)), 0, 0);
intersection.size.width = Math.Min(CCRect.CCRectGetMaxX(r1), CCRect.CCRectGetMaxX(r2)) -
CCRect.CCRectGetMinX(intersection);
intersection.size.height = Math.Min(CCRect.CCRectGetMaxY(r1), CCRect.CCRectGetMaxY(r2)) -
CCRect.CCRectGetMinY(intersection);
return intersection;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment