android AndEngine 获取 Tap(Click) 事件?
我正在使用 AndEngine 并获取触摸事件。 有 OnAreaTouched() 事件,
但我需要获取绘制图像的 TAP 事件(点击)..我可以使用 onAreaTouch 来做到这一点,但即使用户只是触摸,也会给出..我希望用户点击它。建议、示例或教程?
i am using AndEngine and to get touch events.
there is OnAreaTouched() event,
but i need to get TAP event of images drawn (to Click)..i can do that using onAreaTouch but that gives even when user simply touch..i want user to tap on that. Suggestions, examples, or tutorials?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,点击是
ACTION_DOWN
、一些ACTION_MOVE
和ACTION_UP
触摸事件操作的组合,出现在一个小区域中。您所需要做的就是检查您的ACTION_UP
是否出现在ACTION_DOWN
附近。如果您需要额外的准确性,您可以检查这些操作之间的时间间隔,以确保这是一次点击。只需存储ACTION_DOWN
的位置和时间,并将其与ACTION_UP
的位置和时间进行比较 - 您就能够区分点击、猛击或其他操作。希望这有帮助。Basically, a click is a combination of
ACTION_DOWN
, someACTION_MOVE
's and anACTION_UP
touch event actions, that appear in a small area. All you need to do is to check, whether yourACTION_UP
appeared near to yourACTION_DOWN
. If you need some extra accuracy, you can check the time interval between those actions to be sure this was a click. Just store position and time of theACTION_DOWN
and compare it to yourACTION_UP
's position and time - and you'll be able to differentiate click from fling or something else. Hope this helps.