【问题标题】:4 point multitouch gestures in WP7 (silverlight)WP7 中的 4 点多点触控手势(silverlight)
【发布时间】:2012-02-03 17:03:41
【问题描述】:

我想在我的应用程序中使用 4 点多点触控手势。该应用程序处于silverlight(不是xna)中,但手势不会应用于任何控件,它们只会检查用户是否将4根手指拖到屏幕的左侧或右侧。

有没有我可以使用的库?或者我自己实现它的最简单方法是什么?我可以使用 XNA 多点触控库吗?

干杯

【问题讨论】:

    标签: c# silverlight windows-phone-7 multi-touch


    【解决方案1】:

    您可能知道 WP7 silverlight API 假设多点触控有两个接触点,即 PinchStarted、PinchDelta 和 PinchCompleted。

    请查看 Microsoft.Xna.Framework.Input.Touch 命名空间中的 TouchPanel 类。

    //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;
    
        }
    }
    

    更多详情可以在这里找到:http://msdn.microsoft.com/en-us/library/ff827744.aspx

    我没有看到任何专门针对 4 点触控的库,但是,如果您正在寻找有助于多点触控调试的库,我强烈推荐 http://multitouch.codeplex.com/

    【讨论】:

    • 这对 XNA 来说是个好主意,但在 Silverlight 中更好的方法是 Touch.FrameReported 链接:msdn
    【解决方案2】:

    Silverlight WP7 工具包非常适合做手势操作。
    Download WP7 Toolkit
    Then check out this awesome tutorial

    【讨论】:

    • XNA 最多可处理 4 个接触点。您应该可以使用它,但您可能必须使用计时器来读取值。 (工具包中的 GestureHelper 在内部执行此操作,但只给您 2 分)。
    猜你喜欢
    • 1970-01-01
    • 2011-08-22
    • 2020-08-17
    • 1970-01-01
    • 2015-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-12
    相关资源
    最近更新 更多