Edit: You are not using gestures here. A drag gesture is generated each time a finger moves across the screen. If you move your finger from one side of the screen to the other (very fast), you will get many small gestures. This is how XNA and MonoGame work.
This is the logic you are looking for:
var touchCol = TouchPanel.GetState(); foreach (var touch in touchCol) {
If you prefer to make gestures, you can simply do this:
var gesture = default(GestureSample); while (TouchPanel.IsGestureAvailable) { gesture = TouchPanel.ReadGesture(); if (gesture.GestureType == GestureType.DragComplete) { if (gesture.Delta.Y < 0 || gesture.Delta.X < 0) return new RotateLeftCommand(_gameController); if (gesture.Delta.Y > 0 || gesture.Delta.X > 0) return new RotateRightCommand(_gameController); } }
In any case, you get what you are looking for. You still need to put the logic inside the loop, as I said in the original post, because you can have multiple gestures in the queue, and you don't want to assume that the last one on the stack is a drag and drop. (Thanks to multi-touch, you can have drag and drop, taps, drag and drop, etc.).
I am not 100% sure if this is your problem ... but your logic here is wrong. The lead CodeFormatting beats me here, but it should be something like this:
var gesture = default(GestureSample); while (TouchPanel.IsGestureAvailable) { gesture = TouchPanel.ReadGesture(); if (gesture.GestureType == GestureType.VerticalDrag) { if (gesture.Delta.Y < 0) return new RotateLeftCommand(_gameController); if (gesture.Delta.Y > 0) return new RotateRightCommand(_gameController); } if (gesture.GestureType == GestureType.HorizontalDrag) { if (gesture.Delta.X < 0) return new RotateLeftCommand(_gameController); if (gesture.Delta.X > 0) return new RotateRightCommand(_gameController); } }
Without putting TouchPanel.ReadGesure () inside the loop, you only read one argument per frame. Available gestures are queued and deleted only when ReadGesture () is called. Therefore, if your frame rate hiccups, or if you cannot read the gesture as fast as you can read it (which is very possible), you will work with the old information. You can see that here . For this application, I propose to take each gesture and combine it into one or two, and then decide what you should do based on this.