Skip to content

CCLongPressGestureRecognizer

spalx edited this page Apr 30, 2013 · 3 revisions

CCLongPressGestureRecognizer is a subclass of CCGestureRecognizer that looks for long-press gestures. The user must press a finger on a node for at least a specified period for the action method to be called.

Properties

//the minimum period (seconds) the finger must press on the view for the gesture to be recognized
//default value is 0.5
float minimumPressDuration;

Example

CCLongPressGestureRecognizer * longPress = CCLongPressGestureRecognizer::create();
longPress->setTarget(this, callfuncO_selector(HelloWorld::didLongPress));
longPress->setMinimumPressDuration(0.6);
longPress->setCancelsTouchesInView(true);
this->addChild(longPress);

CCLongPress

The CCLongPress object that you receive after a successful long-press recognition, contains the following public members:

//the location of the gesture
CCPoint location;