I try to write a touchable CCSprite to handle the touch event by sprite itself.
So I make a class TouchSprite and inherit from cocos2d::CCSprite and my codes are something like these:
class TouchSprite : public cocos2d::CCSprite, public CCTargetedTouchDelegate
virtual bool init();
virtual void onEnter();
virtual void onExit();
virtual bool ccTouchBegan(CCTouch* touch, CCEvent* event);
virtual void ccTouchMoved(CCTouch* touch, CCEvent* event);
virtual void ccTouchEnded(CCTouch* touch, CCEvent* event);
but when I put a breakpoint under my implementation of init(), it never stops.
I try to trace the code, and I found it does go into the CCSprite::init().
BTW, I use the CCSprite::spriteWithSpriteFrameName(“test.png”) to new the instance of my sprite.
Maybe I need to write a static TouchSprite::spriteWithSpriteFrameName(const char* filename) and do the init() there by myself ??