Time for action – overriding the Update() method – part 1
Create a new region in the
Player
class forPublic Methods
:#Region "Public Methods" #End Region
Add the initial
Update()
override method to thePublic Methods
region of thePlayer
class:Public Overrides Sub Update(gameTime As GameTime) If Not Dead Then Dim newAnimation As String = "idle" Velocity = New Vector2(0, Velocity.Y) Dim padState As GamePadState = GamePad.GetState(PlayerIndex.One) Dim keyState As KeyboardState = Keyboard.GetState() If (keyState.IsKeyDown(Keys.Left) Or (padState.ThumbSticks.Left.X < -0.3F)) Then Flipped = False newAnimation = "run" Velocity = New Vector2(-_moveScale, Velocity.Y) End If If (keyState.IsKeyDown(Keys.Right) Or (padState.ThumbSticks.Left.X > 0.3F)) Then Flipped = True newAnimation = "run" Velocity = New Vector2(_moveScale, Velocity.Y) End If If newAnimation <> CurrentAnimation Then...