The TouchScreen class provides information about the physical touch screen on devices which provide one. This class can be used on Android, iOS, and touch-enabled Windows RT apps. An instance of the TouchScreen class is automatically instantiated and available through the InputManager, so you do not need to instantiate your own. For more information, see the TouchScreen page.
Note: This class does not work for touch screens for Windows 7. Touch screens for Windows 7 are not exposed to the XNA API. You will need to read touch screen input manually. For more information, see this link: http://blogs.msdn.com/b/shawnhar/archive/2010/09/09/touch-input-on-windows-in-xna-game-studio-4-0.aspx
The FlatRedBall TouchScreen provides a thin wrapper and access to the underlying GestureSamples provided by XNA. If you are comfortable using the XNA-provided GestureSample class, you can set the TouchScreen's ReadsGestures property to false. Otherwise, you will want to loop through the LastFrameGestures list and perform actions appropriately.
Did this article leave any questions unanswered? Post any question in our forums for a rapid response.
The ReadsGestures variable controls whether the FlatRedBall TouchScreen instance automatically reads gestures from the . This value is true by default. This means that game code will not be able to read from the native MonoGame's TouchPanel since FlatRedBall has already read the gestures (a read clears out the information). If you would like to use MonoGame code to read gestures, then set the ReadGestures to false.
The LastFrameGestures is a List of GestureSamples representing all gestures read last frame. You can use the LastFrameGestures in your code to respond to gesture input. The LastFrameGestures will only be populated every frame if the ReadsGestures value is true (default is true). For full documentation on how to use GestureSamples, see the Microsoft page on GestureSamples.
The following code shows how to detect all clicks from the TouchScreen: