views:

86

answers:

1

I am using Cocos2d and CCSprite to create sprites in my application. I am wondering if there is any easier way to implement the touch event on the CCSprite object. I know the menuitem provides the selector but what does CCSprite provides to handle the touch events.

A: 

I'm really just starting out with Cocos2D, so I may be wrong, but as far as I've understood, CCSprite doesn't actually have any built-in touch handling, and you need to handle it yourself. Usually this is done by keeping a reference of all sprites in an NSMutableArray which you then, on the touch event, iterate through, doing coordinate checks for each sprite.

Let me know if you need some example code.

hmans
Yup! I think you are right! And that is how I am doing it right now using the pythagorus theorm.
azamsharp