【发布时间】:2012-02-03 17:03:41
【问题描述】:
我想在我的应用程序中使用 4 点多点触控手势。该应用程序处于silverlight(不是xna)中,但手势不会应用于任何控件,它们只会检查用户是否将4根手指拖到屏幕的左侧或右侧。
有没有我可以使用的库?或者我自己实现它的最简单方法是什么?我可以使用 XNA 多点触控库吗?
干杯
【问题讨论】:
标签: c# silverlight windows-phone-7 multi-touch
我想在我的应用程序中使用 4 点多点触控手势。该应用程序处于silverlight(不是xna)中,但手势不会应用于任何控件,它们只会检查用户是否将4根手指拖到屏幕的左侧或右侧。
有没有我可以使用的库?或者我自己实现它的最简单方法是什么?我可以使用 XNA 多点触控库吗?
干杯
【问题讨论】:
标签: c# silverlight windows-phone-7 multi-touch
您可能知道 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/。
【讨论】:
Touch.FrameReported 链接:msdn
Silverlight WP7 工具包非常适合做手势操作。
Download WP7 Toolkit
Then check out this awesome tutorial
【讨论】: