Time for action – overriding the Update() method – part 1
Create a new region in the Player class for public methods:
#region Public Methods #endregion
Add the initial
Update()
override method to the Public Methods region of the Player class:public override void Update(GameTime gameTime) { if (!Dead) { string newAnimation = "idle"; velocity = new Vector2(0, velocity.Y); GamePadState gamePad = GamePad.GetState(PlayerIndex.One); KeyboardState keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.Left) || (gamePad.ThumbSticks.Left.X < -0.3f)) { flipped = false; newAnimation = "run"; velocity = new Vector2(-moveScale, velocity.Y); } if (keyState.IsKeyDown(Keys.Right) || (gamePad.ThumbSticks.Left.X > 0.3f)) { flipped = true; newAnimation = "run"; velocity = new Vector2(moveScale, velocity.Y); } ...