Good afternoon,

I'm starting to understand cocos2d, I just can't find information on my question

There is an object on the screen (myButton name), how do I know if the user clicked on it?

I create a function, and then what? I'm used to hitTest, but what's the philosophy here?

-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
  • one
    And what prevents when creating a button to specify a callback, which will be called at tap? - nitrocaster
  • I do not have a button - just a sprite. Is there such an opportunity? (I do not mean CCMenu) - Rosso777

1 answer 1

Check whether the touch point lies inside this object:

  CGRectContainsPoint (CGRect rect, CGPoint point)` 
  • Understood! Thank! - Rosso777