I've reached a point that it seems when I draw too much on screen, monogame starts doing weird things.
When I call this code in the Draw method
public void drawDialogBox()
{
if (dialogueBoxOn == 1)
{
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(GameGlobals.zoom));
spriteBatch.Draw(dialogBoxChara, new Vector2(89, 18), Color.White);
spriteBatch.Draw(dialogBoxTexture, new Vector2(0, 108), Color.White);
spriteBatch.DrawString(font, "àéùaDASASCZadhkjashdash", new Vector2(4, 108), Color.White);
spriteBatch.End();
}
}
This happens:
This code is supposed to show the character, the textBox itself and the text. But the text isn't drawn correctly. If I comment one of the draw lines, it works.
Or this (if I only comment the character line)
Any ideas of what is happening here? I thought it was some SpriteBatch limitations, but I don't know...
EDIT: After following @Jon advice, i've reached this state
Now it shows the character and dialog properly, but the background and the walls are not displayed now. I have all the walls like this:
spriteBatch.Draw(leftcenterright4, new Vector2(0, 53), null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0.5f);
And the background
spriteBatch.Draw(background, new Vector2(0, 0), null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 1f);
And the code from earlier fixed:
spriteBatch.Draw(dialogBoxChara, new Vector2(89, 18),null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
spriteBatch.Draw(dialogBoxTexture, new Vector2(0, 108),null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0.1f);
spriteBatch.DrawString(font, "àéùaDASASCZadhkjashdash", new Vector2(4, 108), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);