I have subclassed CCSprite class and added a UIRotationGestureRecognizer to it. So, in my init method I have this
UIRotationGestureRecognizer *rot = [[[UIRotationGestureRecognizer alloc]
initWithTarget:self action:@selector(handleRotation:)] autorelease];
[rot setDelegate:self];
[[[CCDirector sharedDirector] openGLView] addGestureRecognizer:rot];
and then I have the method
- (void)handleRotation:(UIRotationGestureRecognizer *)recognizer {
float rotation = [recognizer rotation];
self.rotation += rotation;
}
it works perfectly but it has a huge lag between the actual gesture and the rotation itself. I would say almost 0.5 seconds between the gesture and the sprite response.
How do I solve that? thanks.
NOTE: After the first comment, I have added two more recognizers to the sprite: UIPinchGestureRecognizer and UIPanGestureRecognizer. I have also added the delegate method shouldRecognizeSimultaneouslyWithGestureRecognizer and set that to YES.
After doing this and checking, pinch and pan gestures are fast as hell. On the other hand, rotation continues slow. There was not reduction on the rotation speed by adding these two other gestures recognizer. The other two respond fluid and fast, UIRotationGestureRecognizer is slow.
openGLView
. It is correct to attach the gesture recognizer to that view (as you say, the master view), since it is the only view you have. I also do, and it does not add any delay. If you wereusing more gest. recognizers, then there could be some interacion, I thought – sergio