public override void Update(GameTime gameTime)
        {
            if (!_slideTo.HasValue)
            {
                return;
            }

            //If there is a position to slide to, save starting position and set step to zero
            if (!_currentStep.HasValue)
            {
                //Reset
                _currentStep      = 0;
                _startingPosition = _position;
            }
            else if (_currentStep.Value > SlideUpdateCount)
            {
                _slideTo     = null;
                _currentStep = null;

                //Raise SlideCompleted event if there are any subscribers
                SlideCompletedState handler = SlideCompleted;
                if (handler != null)
                {
                    handler();
                }

                return;
            }

            _position = Vector2.SmoothStep(_startingPosition, _slideTo.Value, (float)_currentStep / (float)SlideUpdateCount);
            _currentStep++;


            base.Update(gameTime);
        }
Esempio n. 2
0
        public PlusOne(Texture2D texture, Vector2 position, Color tintColor)
            : base(texture, position, tintColor)
        {
            _originalColor = tintColor;

            IsVisible        = false;
            SlideUpdateCount = 200;
            SetCenterAsOrigin();

            SlideCompleted += new SlideCompletedState(PlusOne_SlideCompleted);
        }