title: XNA C# HUD SpriteFont
body: <p>I added a SpriteFont to my HUD and this is what I get:</p>
  
  <p><a href="http://i557.photobucket.com/albums/ss13/KookehMonsters/Dev/Untitled-1.png" rel="nofollow">http://i557.photobucket.com/albums/ss13/KookehMonsters/Dev/Untitled-1.png</a></p>
  
  <p>All those white spots are from my camera panning and the text following along.
  What's going on?</p>
  
  <pre><code>        Label displayName = new Label();
  
          displayName.Text = "DisplayName";
          displayName.Size = displayName.SpriteFont.MeasureString(displayName.Text);
          displayName.Position = new Vector2((int)player.Camera.Position.X, (int)player.Camera.Position.Y);
  
          ControlManager.Add(displayName);
  
          ControlManager.Draw(GameRef.SpriteBatch);
  </code></pre>
  
  <p>Label.cs</p>
  
  <pre><code>public class Label : Control
  {
      public Label()
      {
          tabStop = false;
      }
  
      public override void Update(GameTime gameTime)
      {
      }
  
      public override void Draw(SpriteBatch spriteBatch)
      {
          spriteBatch.DrawString(SpriteFont, Text, Position, Color);
      }
  
      public override void HandleInput()
      {
      }
  }
  </code></pre>
  
  <p>Update method from GamePlayScreen.cs</p>
  
  <pre><code>public override void Update(GameTime gameTime)
      {
          player.Update(gameTime);
          sprite.Update(gameTime);
          hud.Update(gameTime);
  
          if (InputHandler.KeyReleased(Keys.Add))
          {
              player.Camera.ZoomIn();
              if (player.Camera.CameraMode == CameraMode.Follow)
                  player.Camera.LockToSprite(sprite);
          }
          else if (InputHandler.KeyReleased(Keys.Subtract))
          {
              player.Camera.ZoomOut();
              if (player.Camera.CameraMode == CameraMode.Follow)
                  player.Camera.LockToSprite(sprite);
          }
  
          Vector2 motion = new Vector2();
  
          if (InputHandler.KeyDown(Keys.W))
          {
              sprite.CurrentAnimation = AnimationKey.Up;
              motion.Y = -1;
          }
          else if (InputHandler.KeyDown(Keys.S))
          {
              sprite.CurrentAnimation = AnimationKey.Down;
              motion.Y = 1;
          }
  
          if (InputHandler.KeyDown(Keys.A))
          {
              sprite.CurrentAnimation = AnimationKey.Up;
              motion.X = -1;
          }
          else if (InputHandler.KeyDown(Keys.D))
          {
              sprite.CurrentAnimation = AnimationKey.Down;
              motion.X = 1;
          }
  
          if (motion != Vector2.Zero)
          {
              sprite.IsAnimating = true;
              motion.Normalize();
  
              sprite.Position += motion * sprite.Speed;
              sprite.LockToMap();
  
              if (player.Camera.CameraMode == CameraMode.Follow)
                  player.Camera.LockToSprite(sprite);
          }
          else
          {
              sprite.IsAnimating = false;
          }
  
          if (InputHandler.KeyReleased(Keys.F))
          {
              player.Camera.ToggleCameraMode();
              if (player.Camera.CameraMode == CameraMode.Follow)
                  player.Camera.LockToSprite(sprite);
          }
  
          if (player.Camera.CameraMode != CameraMode.Follow)
          {
              if (InputHandler.KeyReleased(Keys.C))
              {
                  player.Camera.LockToSprite(sprite);
              }
          }
  
          base.Update(gameTime);
      }
  </code></pre>
  
  <p>Draw method of GamePlayScreen.cs</p>
  
  <pre><code>public override void Draw(GameTime gameTime)
      {
          GameRef.SpriteBatch.Begin(
              SpriteSortMode.Deferred,
              BlendState.AlphaBlend,
              SamplerState.PointClamp,
              null,
              null,
              null,
              player.Camera.Transformation);
  
          map.Draw(GameRef.SpriteBatch, player.Camera);
  
          sprite.Draw(gameTime, GameRef.SpriteBatch, player.Camera);
  
          hud.Draw(gameTime);
  
          base.Draw(gameTime);
  
          GameRef.SpriteBatch.End();
      }
  </code></pre>