如何在 WP7 XNA 中检测 HorizontalDrag 的方向?
正如前面提到的,检测用户水平拖动方向的最佳方法是什么。我正在尝试创建一个响应此手势的相机类,但在确定它们拖动的方向时遇到问题。任何建议表示赞赏。
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. Any suggestions are appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
诚然,我还没有测试过这个,但是 文档建议您应该检查
GestureSample.Delta.X
的值,该值对于向左移动应该为负,对于向右移动应该为正。因为增量仅针对特定手势样本(而不是整个手势),因此您可能需要累积它,并且仅在累积值高于某个阈值时(可能在收到
DragComplete
)。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.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
).