Added offset to be used instead of origin in spritebatch does things I don't want it to do. Also added a project to more easily test this library.

This commit is contained in:
2019-03-01 23:10:53 -06:00
parent 051f3b04b5
commit f311cc38f3
13 changed files with 352 additions and 12 deletions

View File

@@ -24,11 +24,17 @@ namespace RecrownedAthenaeum.UI.Modular
/// Bounds of this module.
/// </summary>
public Rectangle bounds;
/// <summary>
/// The how much of the entire boundary to offset when drawing.
/// </summary>
public Vector2 offset;
/// <summary>
/// Origin of this module.
/// </summary>
public Vector2 origin;
/// <summary>
/// The parent of this module. May be null.
/// </summary>
@@ -59,7 +65,12 @@ namespace RecrownedAthenaeum.UI.Modular
/// <param name="batch">Batch used to draw.</param>
public virtual void Draw(SpriteBatch batch)
{
if (Debugging) { rectangleRenderer.Draw(bounds.X, bounds.Y, bounds.Width, bounds.Height, Color.Red); }
if (Debugging)
{
rectangleRenderer.Begin();
rectangleRenderer.Draw(bounds.X, bounds.Y, bounds.Width, bounds.Height, Color.Red);
rectangleRenderer.End();
}
}
/// <summary>
@@ -115,8 +126,8 @@ namespace RecrownedAthenaeum.UI.Modular
/// </summary>
public void CenterOrigin()
{
origin.X = bounds.Width / 2f;
origin.Y = bounds.Height / 2f;
offset.X = bounds.Width / 2f;
offset.Y = bounds.Height / 2f;
}
}
}