简体   繁体   English

如何检测滑动/轻弹手势?

[英]How do I detect a swiping / flicking gesture?

I want to allow the user to flick a ball that is on screen.我想让用户轻弹屏幕上的球。 The user would tap on the ball and then flick, the velocity / speed of the flick would then dictate initial velocity.用户将点击球然后轻弹,轻弹的速度/速度将决定初始速度。

I took a look at UISwipeGestureRecognizer but it seems like that is more targeted at navigation than flicking.我看了一下UISwipeGestureRecognizer ,但它似乎更针对导航而不是轻弹。

How do I go about implementing this?我该如何实现这个?

I am using Cocos2d and Box2d.我正在使用 Cocos2d 和 Box2d。

Have you considered UIPanGestureRecognizer?你考虑过 UIPanGestureRecognizer 吗? You can get velocity data from that ([panGesture velocityInView:]), and distinguish the initial velocity of the 'swipe' using the state property on the gesture recognizer.您可以从中获取速度数据 ([panGesture velocityInView:]),并使用手势识别器上的 state 属性区分“滑动”的初始速度。

Or is that not sufficient?或者这还不够?

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

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