【问题标题】:Touch gestures in WinRT (using monogame)WinRT 中的触摸手势(使用 monogame)
【发布时间】:2013-11-29 21:21:07
【问题描述】:

我目前有以下代码:

internal void HandleTouch()
{
    TouchPanel.EnabledGestures = GestureType.DragComplete | GestureType.FreeDrag;

    while (TouchPanel.IsGestureAvailable)
    {
        GestureSample gesture = TouchPanel.ReadGesture();

        if (gesture.GestureType == GestureType.DragComplete)
        {
            MyAction(gesture.Delta.X, gesture.Delta.Y);
        }
        else if (gesture.GestureType == GestureType.FreeDrag)
        {
            OtherAction();
        }
    }
}

我遇到的问题是Delta 始终为 0。我在某处读到 Monogame 以不同方式处理拖动手势,但无论我使用这种方法,还是手动遍历触摸集合,我都会遇到同样的问题。

如何更改此值以获得正确的增量值?

【问题讨论】:

    标签: c# xna windows-runtime monogame


    【解决方案1】:

    您可以使用

    实现相同的目标
    TouchCollection touches = TouchPanel.GetState();
    

    然后在您第一次检测到触摸时

    touches.First().State == TouchLocationState.Pressed || touches.First().State == TouchLocationState.Moved
    

    你保存位置touches.First().Position

    然后去检测拖拽结束的时候

    touches.First().State == TouchLocationState.Released
    

    您可以使用Vector2.Distance 计算Delta

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多