Esempio n. 1
0
        /// <summary>
        ///     Updates the given gameTime.
        /// </summary>
        ///
        /// <param name="gameTime"> The game time. </param>
        ///
        /// <seealso cref="Velentr.Sprite.Sprites.Base.VelentrSprite.Update(GameTime)"/>
        public override void Update(GameTime gameTime)
        {
            if (_currentFrameStartTime == TimeSpan.Zero)
            {
                _currentFrameStartTime = gameTime.TotalGameTime;
            }

            // if we've changed animations, set us to the new animation and reset the old one
            if (!_currentAnimation.Equals(CurrentAnimationName))
            {
                Animations[_currentAnimation].Reset();
                _currentFrameStartTime = gameTime.TotalGameTime;
                _currentAnimation      = CurrentAnimationName;
            }

            // update the new animation frame as required
            if (TimeHelpers.ElapsedMilliSeconds(_currentFrameStartTime, gameTime.TotalGameTime) > CurrentAnimation.CurrentFrame.DurationMilliseconds)
            {
                CurrentAnimation.IncrementFrameId();
                _currentFrameStartTime = gameTime.TotalGameTime;
            }
        }