Corona SDK:触摸事件
如何检测屏幕是否被触摸?在我看来,当触摸屏幕并且手指不移动时,不会生成触摸事件。
How can I detect if screen is being touched? Seems to me, touch events are not generated while screen is touched and the finger is not moving.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,仅记录手指运动的变化。放下手指、抬起手指并拖动会触发事件。
Yes, only changes to the finger movement is recorded. Put down finger, lift up finger and dragging around triggers event.
但是,您可以
在事件函数中执行此操作。当用户将手指放在屏幕上时就会触发该操作。
However, you could do
in your event function. That would be triggered when the user puts his finger on the screen.
触摸事件是分阶段处理的。因此,触摸生成的事件有“开始”、“移动”、“结束”和“取消”阶段。因此,您可以通过执行以下操作来使用检测:
当您需要检查屏幕是否被触摸时,只需执行以下操作:
编辑:显然您可以将
addEventListener
行上的“self”更改为任何您希望监听触摸事件的对象Touch events are handled in phases. So the event being generated by the touch has "began", "moved", "ended" and "cancelled" phases. You could use detection, therefore, by doing this:
When you then need to check if the screen is being touched, simply do:
EDIT: Obviously you can change "self" on the
addEventListener
line to be any object you wish to listen for touch events on