I need to do some actions when the user starts touching the screen, moves a finger and then ends a touch. Touch began works fine, move as well, but touch end runs with a delay between 0.5-1 sec. Below there's a code:
-(id) init {
if (self = [super init]) {
//Adding a listener for catching touch events and get call back to selector method
[self addGestureListener:@selector(gestureCallback:)];
CCScene *scene = [CCScene node];
[scene addChild: self];
[[CCDirector sharedDirector] runWithScene:scene];
}
return self;
}
- (UIPanGestureRecognizer *)addGestureListener:(SEL)selector {
UIPanGestureRecognizer *recognizer = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:selector] autorelease];
[[[CCDirector sharedDirector] openGLView] addGestureRecognizer:recognizer];
return recognizer;
}
-(void) gestureCallback:(UIPanGestureRecognizer *) recognizer {
if (recognizer.state == UIGestureRecognizerStateBegan) {
NSLog(@"start");
} else if (recognizer.state == UIGestureRecognizerStateChanged) {
NSLog(@"moved");
} else if (recognizer.state == UIGestureRecognizerStateEnded) {
NSLog(@"ended");
}
}
In the log (last 2 lines) I see this:
2012-10-15 11:29:03.609 App[6169:c07] moved
2012-10-15 11:29:04.267 App[6169:c07] ended
Any ideas?