LastFrameGestures

Introduction

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.

Code Example

The following code shows how to detect all clicks from the TouchScreen:

foreach(var gesture in InputManager.TouchScreen.LastFrameGestures)
{
    if(gesture.GestureType == GestureType.Tap)
    {
        // The user tapped the screen
        float worldX;
        float worldY;
   
        MathFunctions.WindowToAbsolute(
            gesture.Position.X,
            gesture.Position.Y,
            ref worldX,
            ref worldY,
            0,  // The z position
            SpriteManager.Camera,
            CoordinateRelativity.RelativeToWorld);

        // Do whatever is needed with world coordinates here
    }
}

Last updated