示例#1
0
        public override void Update(GameTime gameTime)
        {
            var currentState    = TouchPanel.GetState(_window);
            var touchCollection = currentState.GetState();

            if (touchCollection.Count > 0)
            {
                var first           = touchCollection.FirstOrDefault();
                var currentPosition = Vector2.Transform(first.Position, Global.ScaleMatrix);
                OnMove(currentPosition);
                if (first.State == TouchLocationState.Pressed)
                {
                    _startPressed ??= currentPosition;
                    OnPressedMove(_startPressed.Value, currentPosition);
                }

                if (first.State == TouchLocationState.Released)
                {
                    _startPressed = null;
                    var lastTouchCollection = _state.GetState();
                    if (lastTouchCollection.Count == 0 || lastTouchCollection.FirstOrDefault().State == TouchLocationState.Pressed)
                    {
                        OnPress(currentPosition);
                    }
                }

                _state = currentState;
            }
        }
示例#2
0
        public void InitiallyHasNoTouches()
        {
            var state = _tps.GetState();

            Assert.AreEqual(0, state.Count);
            Assert.AreEqual(true, state.IsReadOnly);
        }