/// <summary> /// Checks for a bounding box intersection of two sprites. Takes /// scaling and origin into account. Ignores rotation. /// </summary> public static bool isIntersecting(Sprite spr1, Sprite spr2) { //Creates smooth rects from the sprite destinations, which //already take scaling into account. SmoothRect tempRect1 = new SmoothRect(spr1.rectDest); SmoothRect tempRect2 = new SmoothRect(spr2.rectDest); //Adjusts the rectangles based on the origin. tempRect1.X -= spr1.origin.X; tempRect1.Y -= spr1.origin.Y; tempRect2.X -= spr2.origin.X; tempRect2.Y -= spr2.origin.Y; if (SmoothRect.IsIntersecting(tempRect1, tempRect2)) { return(true); } return(false); }
/// <summary> /// Checks for a bounding box intersection of two sprites. Takes /// scaling and origin into account. Ignores rotation. /// </summary> public static bool isIntersecting(Sprite spr1, SmoothRect rect2) { //Creates smooth rects from the sprite and another rectangle, //which already take scaling into account. SmoothRect tempRect1 = new SmoothRect(spr1.rectDest); SmoothRect tempRect2 = new SmoothRect(rect2); //Adjusts the rectangles based on the origin. if (!spr1.originOffset) { tempRect1.X -= spr1.origin.X; tempRect1.Y -= spr1.origin.Y; } if (SmoothRect.IsIntersecting(tempRect1, tempRect2)) { return(true); } return(false); }