Time for action – building the GameObject class – part 2
Add the
updateAnimation()
helper method to theGameObject
class:#Region "Helper Methods" Private Sub updateAnimation(gameTime As GameTime) If _animations.ContainsKey(CurrentAnimation) Then If _animations(CurrentAnimation).FinishedPlaying Then PlayAnimation(_animations(CurrentAnimation). NextAnimation) Else _animations(CurrentAnimation).Update(gameTime) End If End If End Sub #End Region
Add a new region called Public Methods to the
GameObject
class:#Region "Public Methods" #End Region
Inside the Public Methods region, add the
PlayAnimation()
method:Public Sub PlayAnimation(name As String) If Not IsNothing(name) AndAlso _animations.ContainsKey(name) Then _currentAnimation = name _animations(name).Play() End If End Sub
Still in the Public Methods region, add the
Update()
method:Public Overridable Sub Update(gameTime As GameTime) If Not Enabled...