Implemented spritebatch's method of handling the origin.
This commit is contained in:
@@ -21,14 +21,20 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
public bool Debugging { set { if (value) { if (rectangleRenderer == null) rectangleRenderer = new RectangleRenderer(); } else { rectangleRenderer?.Dispose(); rectangleRenderer = null; } } get { return rectangleRenderer != null; } }
|
||||
|
||||
/// <summary>
|
||||
/// Bounds of this module.
|
||||
/// The bounds before factoring in the origin.
|
||||
/// </summary>
|
||||
public Rectangle bounds;
|
||||
|
||||
/// <summary>
|
||||
/// The how much of the entire boundary to offset when drawing.
|
||||
/// Bounds of this module (after factoring in the origin).
|
||||
/// </summary>
|
||||
public Vector2 offset;
|
||||
public Rectangle ActualBounds
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Rectangle((int)(bounds.X - origin.X), (int)(bounds.Y - origin.Y), bounds.Width, bounds.Height);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Origin of this module.
|
||||
@@ -68,7 +74,7 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
if (Debugging)
|
||||
{
|
||||
rectangleRenderer.Begin();
|
||||
rectangleRenderer.Draw(bounds.X, bounds.Y, bounds.Width, bounds.Height, Color.Red);
|
||||
rectangleRenderer.Draw(ActualBounds.X, ActualBounds.Y, ActualBounds.Width, ActualBounds.Height, Color.Red);
|
||||
rectangleRenderer.End();
|
||||
}
|
||||
}
|
||||
@@ -126,8 +132,8 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
/// </summary>
|
||||
public void CenterOrigin()
|
||||
{
|
||||
offset.X = bounds.Width / 2f;
|
||||
offset.Y = bounds.Height / 2f;
|
||||
origin.X = bounds.Width / 2f;
|
||||
origin.Y = bounds.Height / 2f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user