Suppose I have grossini animated using a spriteSheet, and I also have him moving about the screen via an action CCSequence. My user is supposed to touch him, and I expect to use CGRectContainsPoint to see if the touch point is in the grossini frame at the time. But how does one select the correct frame? See some attempts below, but the tRect I think is wrong in both cases. How to find suitable rectangle?
- (BOOL)containsTouchLocation:(UITouch *)touch
{
#if 1
CGPoint location = [touch locationInView:[touch view]];
CGPoint convertedLocation = [[CCDirector sharedDirector] convertToGL:location];
CGRect tRect= grossini.textureRect;
CGPoint tapPosition = [self convertToNodeSpace:convertedLocation];
NSLog(@"tRect(%f %f) tapPos(%f %f)", tRect.size.width, tRect.size.height, tapPosition.x, tapPosition.y);
return CGRectContainsPoint(tRect, tapPosition);
#else
CGRect tRect = [[grossini displayedFrame] rectInPixels];
CGPoint tapPosition = [self convertTouchToNodeSpaceAR:touch];
NSLog(@"tRect(%f %f) tapPos(%f %f)", tRect.size.width, tRect.size.height, tapPosition.x, tapPosition.y);
return CGRectContainsPoint(tRect, tapPosition);
#endif
}