-
Notifications
You must be signed in to change notification settings - Fork 59
CCSwipeGestureRecognizer
Valentin-Costel Hăloiu edited this page Sep 21, 2013
·
12 revisions
CCSwipeGestureRecognizer is a subclass of CCGestureRecognizer that looks for swiping gestures in one or more directions. A swipe is a discrete gesture, and thus the associated action method is called only once per gesture.
//the permitted direction(s) of the swipe for this gesture recognizer.
int direction;
CCSwipeGestureRecognizer * swipe = CCSwipeGestureRecognizer::create();
swipe->setTarget(this, callfuncO_selector(HelloWorld::didSwipe));
swipe->setDirection(kSwipeGestureRecognizerDirectionRight | kSwipeGestureRecognizerDirectionLeft);
swipe->setCancelsTouchesInView(true);
this->addChild(swipe);
The CCSwipe object that you receive after a successful swipe recognition, contains the following public members:
//direction of the swipe gesture that fired the target method
//NOTE: it doesn't matter how many directions you set when creating the gesture recognizer,
//you will receive the first one which was confirmed as a swipe gesture
CCSwipeGestureRecognizerDirection direction;
//the initial location where the swipe started
CCPoint location;
- kSwipeGestureRecognizerDirectionRight
- kSwipeGestureRecognizerDirectionLeft
- kSwipeGestureRecognizerDirectionUp
- kSwipeGestureRecognizerDirectionDown