I have been looking for a solution to this for a couple of days now, and can't seem to figure it out. I am trying to detect if a sprite has been touched, and if so, call a particular method. Here is my code:
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
CGPoint converted = [[CCDirector sharedDirector] convertToGL:location];
if(CGRectContainsPoint([factBubble textureRect], touchLocation)) {
int randomNumber = arc4random() % [factArray count];
NSString *fact = [factArray objectAtIndex:randomNumber];
[self showFact:fact];
[fact release];
}
}
What am I missing here?