I setup a touch event for a sprite and it works only when I touch part of the sprite not the whole sprite.... it's as though the CGRect is some how offset but I'm not sure, here is my code below, I am using cocos2d 8.1:
- (BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
CGPoint convertedPoint = [[Director sharedDirector] convertCoordinate:location];
CGRect myRect = CGRectMake(mySprite.position.x, mySprite.position.y, mySprite.contentSize.width, mySprite.contentSize.height);
if (CGRectContainsPoint(myRect, convertedPoint)) {
//Whatever action
return kEventHandled;
}
}