public static float GetSpriteFontCenterPoint(Rectangle parentBounds, Vector2 location, SpriteFont spriteFont, string text, CenterPointType pointType) { float spriteFontCenter; if (pointType == CenterPointType.X) { spriteFontCenter = (parentBounds.Width / 2) - (spriteFont.MeasureString(text).X / 2) + location.X; } else { spriteFontCenter = (parentBounds.Height / 2) - (spriteFont.MeasureString(text).Y / 2) + location.Y; } return(spriteFontCenter); }
public static float GetTextureCenterPoint(Rectangle parentBounds, Vector2 location, Texture2D texture, CenterPointType pointType) { float textureCenter; if (pointType == CenterPointType.X) { textureCenter = (parentBounds.Width / 2) - (texture.Width / 2) + location.X; } else { textureCenter = (parentBounds.Height / 2) - (texture.Height / 2) + location.Y; } return(textureCenter); }