Example #1
0
        public void UpdateThreshold()
        {
            _topLeft     = (_centerPosition - _originScaledDraw);
            _bottomRight = (_centerPosition + _originScaledDraw);

            //Set Touch Thresholds Bouund Based on Viewing Threasholds
            _leftThreshold   = Pax4Tools.BoundOutput((int)_topLeft.X, Pax4Game._graphicsDeviceManager.PreferredBackBufferWidth, _leftViewingThreshold);
            _rightThreshold  = Pax4Tools.BoundOutput((int)_bottomRight.X, _rightViewingThreshold);
            _topThreshold    = Pax4Tools.BoundOutput((int)_topLeft.Y, Pax4Game._graphicsDeviceManager.PreferredBackBufferHeight, _topViewingThreshold);
            _bottomThreshold = Pax4Tools.BoundOutput((int)_bottomRight.Y, _bottomViewingThreshold);
            //_leftThreshold = (int)(_centerPosition.X - _originScaledDraw.X);
            //_rightThreshold = (_leftThreshold + _rectangleScaled.Width);
            //_topThreshold = (int)(_centerPosition.Y - _originScaledDraw.Y);
            //_bottomThreshold = (_topThreshold + _rectangleScaled.Height);
            SetRectangleDraw();
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (_isDisabled) //Added by Pony
            {
                return;
            }

            bool onetap = false;

            _accelerate = false;

            if (ViewableTouched())
            {
#if WINDOWS
                if (Pax4Touch._current._currentTouchState._clean && Pax4Touch._current._currentTouchState._oneTouch)
#else
                if (Pax4Touch._current._currentTouchState._clean)
#endif
                {
                    _oneTouch = true;

                    _positionModifier.Stop();

                    _tempPosition = _centerPosition;
                    if (_verticalScroll)
                    {
                        _tempPosition.Y += Pax4Touch._current._currentTouchState._dxdy.Y;
                    }
                    else
                    {
                        _tempPosition.X += Pax4Touch._current._currentTouchState._dxdy.X;
                    }

                    SetPositionAbsolute(_tempPosition);

                    _accelerate = true;
                }
                else
                {
                    onetap  = true;
                    _oneTap = Pax4Touch._current._currentTouchState._oneTap;
                }
            }
            else
            { // Cause Flick If touch moves outside Viewable Touch Area
                if (Pax4Touch._current._velocityAvgVal > 30 && _oneTouch)
                {
                    _oneFlick   = true;
                    _accelerate = true;
                    _oneTap     = false;
                    //Pax4Touch._current._currentTouchState._oneTap = false;
                }

                _oneTouch = false;
            }

            if (onetap || _oneFlick)
            {
                if (_oneTouch)
                {
                    if (Pax4Touch._current._currentTouchState._oneFlick)
                    {
                        _accelerate = true;
                    }

                    _oneTouch = false;
                }

                if (_accelerate)
                {
                    if (_verticalScroll)
                    {
                        _velocity.X = 0.0f;
                        _velocity.Y = Pax4Touch._current._velocityAvg.Y;
                    }
                    else
                    {
                        _velocity.X = Pax4Touch._current._velocityAvg.X;
                        _velocity.Y = 0.0f;
                    }

                    _positionModifier.IniVelocity0Acceleration(_velocity, 0.40f, Vector2.Zero, Pax4Game._current.GetPreferredBackBufferVector(), true);
                    _positionModifier.Trigger();

                    _accelerate = false;

                    onetap    = false;
                    _oneFlick = false;
                }
            }

            if (_positionModifier != null && !_positionModifier._done)
            {
                _positionModifier.Update(gameTime);
            }

            //Recover From children being thrown off screen
            if (_childSprite.Count > 0 && !_oneTouch && !_oneTap)
            {
                var lastChildTopLeft      = _childSprite[_childSprite.Count - 1]._centerPositionDraw - _childSprite[_childSprite.Count - 1]._originScaledDraw;
                var firstChildBottomRight = _childSprite[0]._centerPositionDraw + _childSprite[0]._originScaledDraw;

                var bounded = false;

                _tempPosition = _centerPosition;

                if (!_verticalScroll)
                {
                    bounded = Pax4Tools.BoundOutput(ref _tempPosition.X,
                                                    (_centerPositionDraw - firstChildBottomRight).X + _rightViewingThreshold,
                                                    _leftViewingThreshold - (lastChildTopLeft - _centerPositionDraw).X);
                }
                else
                {
                    bounded = Pax4Tools.BoundOutput(ref _tempPosition.Y,
                                                    (_centerPositionDraw - firstChildBottomRight).Y + _bottomViewingThreshold,
                                                    _topViewingThreshold - (lastChildTopLeft - _centerPositionDraw).Y);
                }

                if (bounded)
                {
                    //Recover if PositionModifier is Done moving Or if all Children are not visable.
                    if (_positionModifier != null && (_positionModifier._done || (_childSprite[_childSprite.Count - 1]._isInvisible && _childSprite[0]._isInvisible)))
                    {
                        _positionModifier.Ini(_centerPosition, _tempPosition, .3f);
                        _positionModifier.Trigger();
                    }
                }
            }

            if (_childSprite != null)
            {
                for (int i = 0; i < _childSprite.Count; i++)
                {
                    _childSprite[i].Update(gameTime);
                    _childSprite[i].SetDisabledInvisible();
                }
            }
        }