Standard method for detecting swipes?


#1

Hello,
Is there any standard way that cocos2d-x developers detect swipes? In particular, I am looking for a way to differentiate between up/down/left/right swipes. It looks like one method on cocos2d is to use something like a ccTouchesBegan method to determine the touch origin, and then a ccTouchesMoved method to determine the swipe destination. Then the coordinates of origin and destination can be used to determine the direction (e.g. http://www.raywenderlich.com/14393/how-to-make-a-game-like-fruit-ninja-with-box2d-and-cocos2d-part-2). Is this the best way to accomplish the goal? I see that other users have come up with what look like fairly robust solutions (http://www.cocos2d-x.org/boards/6/topics/23011?r=23044), I am just curious if there is a common, best-practice way to do this?

Thanks for you time!


#2

Interesting question. I guess, we should see the the difference of X and Y coordinates regarding to initial position while listening touch move. The direction should determine the biggest shift.