Search code examples
c#fontsxnadrawstringspritebatch

XNA C# Drawstring weird boxes


Image: https://i.sstatic.net/53Ms1.png
I have been working with XNA some time now and this is the first time this has accured
The blacktext is supposed to say "Orc" and the purple "1 / 100" as in experience
However this does not seem to work, it seems as if the text and the backcolor are the same.

This is the drawstring code:

spritebatch.DrawString(basicFont, Player.Name, new Vector2(
                camera.Pos.X - 250, camera.Pos.Y + 85), Color.Black);
spritebatch.DrawString(basicFont, Player.curEXP.ToString() +
                " / " + Player.maxEXP, new Vector2(camera.Pos.X - 185,
                   camera.Pos.Y + 220), Color.Purple);

Basicfont:

<FontName>Kootenay</FontName>
<Size>12</Size>
<Spacing>0</Spacing>
<UseKerning>true</UseKerning>
<Style>Regular</Style>

I thought it could be because the HUD image is a little transparent so I drew some strings on the background which has the same effect.
I made a new font and the same thing happends.


Solution

  • It worked. Thank you Kikaimaru.

    I had to change SpriteBlendMode to AlphaBlend.

    spritebatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred,
                       SaveStateMode.None, camera.viewMatrix);