Пример #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Enabled)
            {
                _previousPosition.X = _position.X;
                _previousPosition.Y = _position.Y;
                _previousDistance.X = _distance.X;
                _previousDistance.Y = _distance.Y;

                // Physics
                if (_enableDefaultPhysics)
                {
                    _position += _velocity * _acceleration;
                    _velocity *= _maxVelocity;
                }

                if (_hasAnimation)
                {
                    _animator.Update(gameTime);

                    if (_previousDistance == Vector2.Zero && _animator.CurrentAnimationName != String.Empty)
                    {
                        _sourceRectangle = _animator.GetCurrentAnimation().Rectangle[0];
                    }
                }
            }
        }