I am working on a 3D spaceship with XNA 3.1
I tried to separate my drawing code from the game logic (this was conceived by XNA, which makes it almost).
I use a special static class that draws my models on the screen ... the main class of the game uses this code when drawing:
protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.Black); // Draws the stage (the skybox and objects like rocks) stageManager.Draw(gameTime, GraphicsDevice, camera); // Draws each player and each Enemy on stage given the camera foreach (Player p in players) p.Draw(camera); foreach(Enemy e in enemies) e.Draw(camera); if(Configuration.Debug) col.renderColBoundings(GraphicsDevice, camera); GraphicHelper.drawOverlayText("50", "10"); // "Error" line... base.Draw(gameTime); }
But when I draw the text, something strange arises ... Here is the image ( original ): 
As you can see, everything looks overlapping (but in place) ... Like the turbines of a spaceship.
The code inside GraphicHelper.drawOverlayText is as follows:
public static void drawOverlayText(String p1Hp, String currEnemies) { string text1 = "Player1: " + p1Hp; string text2 = "Enemies: " + currEnemies + "/10"; string text3 = "Space Hogs Beta"; spriteBatch.Begin();
And this static class has the following attributes:
static ContentManager content; static GraphicsDevice graphics; static Camera camera; static Dictionary<String, Model> models = new Dictionary<string, Model>(); static SpriteBatch spriteBatch; static SpriteFont font; public static void initHelper(ContentManager c, GraphicsDevice g, Camera cam) { content = c; graphics = g; camera = cam; spriteBatch = new SpriteBatch(g); font = c.Load<SpriteFont>("Fonts/main"); }
I hope you help me :)
source share