Skip to content

CCTapGestureRecognizer

spalx edited this page Apr 30, 2013 · 6 revisions

CCTapGestureRecognizer is a subclass of CCGestureRecognizer that looks for single or multiple taps. For the gesture to be recognized, a finger must tap the parent node a specified number of times.

Properties

//the number of taps for the gesture to be recognized.
unsigned int numberOfTapsRequired;

Example

CCTapGestureRecognizer * tap = CCTapGestureRecognizer::create();
tap->setTarget(this, callfuncO_selector(HelloWorld::didTap));
tap->setNumberOfTapsRequired(2);
tap->setCancelsTouchesInView(true);
this->addChild(tap);

CCTap

The CCTap object that you receive after a successful tap recognition, contains the following public members:

//the location of the gesture; if there are multiple taps, this location is the last tap
CCPoint location;