同时点击2个位置

时间:2015-01-24 10:54:54

标签: c# .net xaml windows-phone-8 windows-phone-8.1

我目前正在开发一款可与朋友一起玩多人分屏的应用。你需要点击按钮来收集掉落的形状,但我发现当玩家1和玩家2同时按下屏幕时,点击事件就不起作用/做任何事情。

当他们不同时点击时,事件会完美地发挥作用。我无法在谷歌上找到任何相关信息。

这是以下屏幕截图中按钮上的点击代码。

private void Left(object sender, System.Windows.Input.GestureEventArgs e)
{
    Player.Margin = new Thickness(14, 660, 0, 0);
    PlayerShadow.Margin = new Thickness(16, 660, 0, 0);

}

private void Middle(object sender, System.Windows.Input.GestureEventArgs e)
{
    Player.Margin = new Thickness(135, 660, 0, 0);
    PlayerShadow.Margin = new Thickness(137, 660, 0, 0);

}

private void Right(object sender, System.Windows.Input.GestureEventArgs e)
{
    Player2.Margin = new Thickness(256, 660, 0, 0);
    PlayerShadow2.Margin = new Thickness(258, 660, 0, 0);

}

private void Right2(object sender, System.Windows.Input.GestureEventArgs e)
{
    Player2.Margin = new Thickness(377, 660, 0, 0);
    PlayerShadow2.Margin = new Thickness(379, 660, 0, 0);

}

这是我的应用在调试时的屏幕截图,只是为了举例说明我的意思。

Screenshot of app while debugging

1 个答案:

答案 0 :(得分:0)

挂钩Touch.FrameReported事件。

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    Touch.FrameReported += Touch_FrameReported; 
}

void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
    TouchPointCollection points = e.GetTouchPoints(this);

    // TODO: do whatever you want with the points
}