简体   繁体   English

如何在 WP7 XNA 中检测 HorizontalDrag 的方向?

[英]How to detect direction of HorizontalDrag in WP7 XNA?

Like mentioned what is the best way of detecting in which direction the user is dragging horizontally.就像提到的那样,检测用户水平拖动方向的最佳方法是什么。 I'm trying to create a camera class that responds to this gesture but am having problems determining which direction they are dragging.我正在尝试创建一个响应此手势的相机 class,但在确定它们拖动的方向时遇到问题。 Any suggestions are appreciated.任何建议表示赞赏。

Admittedly I haven't tested this, but the documentation suggests that you should check the value of GestureSample.Delta.X , which should be negative for a left movement, and positive for a rightwards one.诚然,我没有对此进行测试,但文档建议您检查GestureSample.Delta.X的值,该值对于向左移动应该是负数,对于向右移动应该是正数。

Because the delta is only for that particular gesture sample (not the overall gesture), you may need to accumulate it, and only trigger your drag action if the accumulated value is above some threshold (possibly upon receiving a DragComplete ).因为增量仅适用于该特定手势样本(而不是整体手势),您可能需要累积它,并且仅在累积值高于某个阈值时触发您的拖动操作(可能在收到DragComplete )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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