Skip to content

CCGestureRecognizer

spalx edited this page Apr 29, 2013 · 13 revisions

CCGestureRecognizer is an abstract base class for gesture recognizer classes.

The subclasses of CCGestureRecognizer are the following:

  • CCTapGestureRecognizer
  • CCPinchGestureRecognizer
  • CCSwipeGestureRecognizer
  • CCPanGestureRecognizer
  • CCLongPressGestureRecognizer

Recognizing gestures on specific nodes

The frame of the CCNode object (CCSprite, CCLayer, etc.) on which a gesture recognizer is added that's the space where the gesture recognizer is available. So if you add a gesture recognizer on a "screen-size" CCLayer you will be able to recognize the gesture everywhere on the screen. This is a great feature when you need to recognize gestures on specific parts of the screen.

Setting the target

When a gesture is recognized, your specified method gets called. You can set the method which you want to be called by the following way:

swipe->setTarget(this, callfuncO_selector(HelloWorld::didSwipe));

Canceling touches on other nodes

Clone this wiki locally