New to the input engine within the Focused Games Framework is the gesture recognition capabilities, housed in the GestureTracker class. The gesture recognition class currently supports a small subset of the gestures I plan on supporting, but all are useful none-the-less. The included gestures are press, two fingered press, swipe, two fingered swipe, zoom and pinch. To use the gesture recognition, instantiate a GestureTracker object, add it to the IGame.Modules list and then listen to its GestureTracked even. You will also need an instance of the InputManager class added to the list of modules.
The following is a small sample taken from one of my games that handles some simple menu swiping (a full sample is on the way).
If you do happen to use FGF, I would love to hear what you think! Drop me a line via the Contact form or leave a comment here.
private void OnGestureTracked(object sender, GestureArgs args)
{
// If it wasn't a swipe, we don't care!
if (args.Gesture != Gesture.Swipe) return;
// Get the direction of the swipe to determine what way
// the menus should move
if (args.Direction.X < 0)
{
// If we are capped at the right side of the menus, return
if (current == menus.Length - 1) return;
// Transition the menus
menus[current].Transition(Menu.MoveDir.OffToLeft);
current++;
menus[current].Transition(Menu.MoveDir.OnFromRight);
}
else
{
if (current == 0) return;
menus[current].Transition(Menu.MoveDir.OffToRight);
current--;
menus[current].Transition(Menu.MoveDir.OnFromLeft);
}
}