开发者

How do I detect a swiping / flicking gesture?

开发者 https://www.devze.com 2023-03-20 18:20 出处:网络
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 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 target开发者_开发问答ed 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消