title: Character Movement: How to pause character when not moving. XNA
body: <p>I'm trying to stop my character from doing its animation when there is no movement or action keys pressed.<br>
  I have a function that pauses the animation but I'm not sure how to implement it without stopping the characters movement completely.</p>
  
  <p>Here's what I'm doing in my <code>PlayerSprite</code> update:</p>
  
  <pre class="lang-cs prettyprint-override"><code> this.move = (int)(GameData.PLAYER_MOVE_INCREMENT * gameTime.ElapsedGameTime.Milliseconds);
   if (SpriteManager.GAME.KEYBOARDMANAGER.isKeyDown(leftKey))
   {
       MoveBy(-move, 0);
       this.PRESENTATIONINFO.SPRITEEFFECTS = SpriteEffects.FlipHorizontally;
   }
   if (SpriteManager.GAME.KEYBOARDMANAGER.isKeyDown(rightKey))
   {
       MoveBy(move, 0);
       this.PRESENTATIONINFO.SPRITEEFFECTS = SpriteEffects.None;
   }
   if (SpriteManager.GAME.KEYBOARDMANAGER.isFirstKeyPress(Keys.Space))
   {
       bPause = !bPause;
   }
  </code></pre>
  
  <p>The animation will pause when i press space bar but i want it to pause when there are no keys pressed to give the effect of the character standing still.</p>
  
  <p>Thanks in advance.</p>
  
  <p>I fixed it by doing this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>bPause = true;
  this.move = (int)(GameData.PLAYER_MOVE_INCREMENT * gameTime.ElapsedGameTime.Milliseconds);
  if (SpriteManager.GAME.KEYBOARDMANAGER.isKeyDown(leftKey))
  {
      bPause = false;
      MoveBy(-move, 0);
      this.PRESENTATIONINFO.SPRITEEFFECTS = SpriteEffects.FlipHorizontally;
  }
  if (SpriteManager.GAME.KEYBOARDMANAGER.isKeyDown(rightKey))
  {
      bPause = false;
      MoveBy(move, 0);
      this.PRESENTATIONINFO.SPRITEEFFECTS = SpriteEffects.None;
  }
  if (SpriteManager.GAME.KEYBOARDMANAGER.isFirstKeyPress(Keys.Space))
  {
      bPause = false;
  }
  </code></pre>