I have my sprites on screen and I have a vector that stores each sprite.
Can a CCSprite* handle a touch event? Or just the CCLayer*?
What is the best way to decide what sprite was touched? Should I store the coordinates of where the sprite is (in the sprite class) and when I get the event, see if where the user touched is where the sprite is by looking through the vector and getting each sprites current coordinates?
UPDATE: I subclass CCSprite:
class Field : public cocos2d::CCSprite, public cocos2d::CCTargetedTouchDelegate
and I implement functions:
cocos2d::CCRect rect(); virtual void onEnter(); virtual void onExit();
bool containsTouchLocation(cocos2d::CCTouch* touch);
virtual bool ccTouchBegan(cocos2d::CCTouch* touch, cocos2d::CCEvent* event);
virtual void ccTouchMoved(cocos2d::CCTouch* touch, cocos2d::CCEvent* event);
virtual void ccTouchEnded(cocos2d::CCTouch* touch, cocos2d::CCEvent* event);
virtual void touchDelegateRetain();
virtual void touchDelegateRelease();
I put CCLOG statements in each one and I dont hit them!
When I touch the CCLayer this sprite is on though I do hit those in the class that implements the Layer and puts these sprites on the layer.