SpriterBetaXNA/SpriterBetaXNA/Game1.cs
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
Allows the game to run logic such as updating the world,
checking for collisions, gathering input, and playing audio.
Allows the game to run logic such as updating the world checking for collisions gathering input and playing audio .
protected override void Update(GameTime gameTime) {
      if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)||(Keyboard.GetState().IsKeyDown(Keys.Escape)))
        this.Exit();
      KeyboardState newKeyState = Keyboard.GetState();
      GamePadState newPadState = GamePad.GetState(PlayerIndex.One);
      bool changeAnimation = false;
      if ((newPadState.Buttons.A != ButtonState.Pressed)&&(prevPadState.Buttons.A==ButtonState.Pressed)) {
        changeAnimation = true;
      }
      if ((!newKeyState.IsKeyDown(Keys.Space)) && (prevKeyState.IsKeyDown(Keys.Space))) {
        changeAnimation = true;
      }
      if ((!newKeyState.IsKeyDown(Keys.X)) && (prevKeyState.IsKeyDown(Keys.X)))
      {
          hero.FlipX = !hero.FlipX;
      }
      if ((!newKeyState.IsKeyDown(Keys.Y)) && (prevKeyState.IsKeyDown(Keys.Y)))
      {
          hero.FlipY = !hero.FlipY;
      }
      prevKeyState = newKeyState;
      prevPadState = newPadState;
      if (changeAnimation) {
        int num = hero.CurrentSequence;
        num++;
        if (num >= hero.SequenceCount)
          num = 0;
        hero.CurrentSequence = num;
      }
      hero.Update(gameTime);
      base.Update(gameTime);
    }
protected override void Update ( GameTime gameTime ) { if ( ( GamePad . GetState ( PlayerIndex . One ) . Buttons . Back == ButtonState . Pressed ) || ( Keyboard . GetState ( ) . IsKeyDown ( Keys . Escape ) ) ) this . Exit ( ) ; KeyboardState newKeyState = Keyboard . GetState ( ) ; GamePadState newPadState = GamePad . GetState ( PlayerIndex . One ) ; bool changeAnimation = false ; if ( ( newPadState . Buttons . A != ButtonState . Pressed ) && ( prevPadState . Buttons . A == ButtonState . Pressed ) ) { changeAnimation = true ; } if ( ( ! newKeyState . IsKeyDown ( Keys . Space ) ) && ( prevKeyState . IsKeyDown ( Keys . Space ) ) ) { changeAnimation = true ; } if ( ( ! newKeyState . IsKeyDown ( Keys . X ) ) && ( prevKeyState . IsKeyDown ( Keys . X ) ) ) { hero . FlipX = ! hero . FlipX ; } if ( ( ! newKeyState . IsKeyDown ( Keys . Y ) ) && ( prevKeyState . IsKeyDown ( Keys . Y ) ) ) { hero . FlipY = ! hero . FlipY ; } prevKeyState = newKeyState ; prevPadState = newPadState ; if ( changeAnimation ) { int num = hero . CurrentSequence ; num ++ ; if ( num >= hero . SequenceCount ) num = 0 ; hero . CurrentSequence = num ; } hero . Update ( gameTime ) ; base . Update ( gameTime ) ; }
Allows the game to run logic such as updating the world,
checking for collisions, gathering input, and playing audio.
Allows the game to run logic such as updating the world checking for collisions gathering input and playing audio .
// Allows the game to exit // silly keyboard/gamepad read routines to see if a button is pressed and released // change displayed animation sequence // update hero animation
gameTime
GameTime
Provides a snapshot of timing values.
Provides a snapshot of timing values .