简体   繁体   中英

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.

How do I go about implementing this?

I am using Cocos2d and Box2d.

Have you considered 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.

Or is that not sufficient?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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