简体   繁体   中英

4 point multitouch gestures in WP7 (silverlight)

I want to use 4 point multitouch gestures in my app. The app is in silverlight (not xna), but the gestures won't apply to any controls, they will just check if user drags 4 fingers to the left or to the right of the screen.

Are there any libraries that I can use? Or what is the easiest way to implement it on my own? Can I use XNA multitouch libraries?

Cheers

As you are probably aware the WP7 silverlight API makes the assumption of two contact points for multi touch ie PinchStarted, PinchDelta, and PinchCompleted.

Please Check out the TouchPanel class which is in the Microsoft.Xna.Framework.Input.Touch namespace.

//Determine the maximum number of touches permited (four for WP7):
TouchPanelCapabilities tc = TouchPanel.GetCapabilities();
if(tc.IsConnected)
{
    return tc.MaximumTouchCount;
}

//To read multitouch data from the touch input device you can do the following:
// Process touch events
TouchCollection touchColl = TouchPanel.GetState();
foreach (TouchLocation t in touchColl)
{
    if ((t.State == TouchLocationState.Pressed)
            || (t.State == TouchLocationState.Moved))
    {
    //You can check the coordinates of each point (and the previous coordinate TryGetPreviousLocation())
    float xcoordiante = t.Position.X;
    float ycoordiante = t.Position.Y;

    //Determine if touch point was moved/pressed or released use the State property
    TouchLocationState st = t.State;

    }
}

More details can be found here: http://msdn.microsoft.com/en-us/library/ff827744.aspx

I have not seen any libraries that specifically target 4 point touch, however, if you are looking for libraries that help with multi touch debugging I would strongly recommend http://multitouch.codeplex.com/ .

The Silverlight WP7 Toolkit is awesome for doing Gesture stuff.
Download WP7 Toolkit
Then check out this awesome tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM