I'm struggling with getting the depth layer to work properly. No matter what I do, the line is drawn over the top of the circle texture.
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Begin(
SpriteSortMode.BackToFront,
BlendState.AlphaBlend,
null,
null,
null,
null,
Camera.getTranslation());
// Draw all planets
foreach (PlanetNode p in planets)
{
p.Draw(spriteBatch);
}
spriteBatch.End();
}
PlanetNode's Draw:
public void Draw(SpriteBatch spriteBatch)
{
// Draw forwarding line
if (resourceForward)
{
double dist = Math.Sqrt(Math.Pow(location.X - forwardTo.location.X, 2) +
Math.Pow(location.Y - forwardTo.location.Y, 2));
float angle = Utility.GetAngle(location, forwardTo.location);
spriteBatch.Draw(Textures.BlackPixel, new Rectangle((int)location.X, (int)location.Y, (int)dist, 1), null, Color.Black, angle, Vector2.Zero, SpriteEffects.None, 0.9f);
}
// Draw Planet
if (mouseOver)
{
Color c = new Color(color.R + 0.2f, color.G + 0.2f, color.B + 0.2f);
spriteBatch.Draw(Textures.Planet, position, null, c, 0f, texOrigin, SpriteEffects.None, 0.5f);
}
else
spriteBatch.Draw(Textures.Planet, position, null, color, 0f, texOrigin, SpriteEffects.None, 0.5f);
// Draw overlay text
Vector2 size = Textures.TextFont.MeasureString(resources.ToString());
spriteBatch.DrawString(Textures.TextFont, resources.ToString(), new Vector2(position.X - size.X / 2, position.Y - size.Y / 2), Color.Black);
}