onEnterTransitionDidFinish, onEnter, registerWithTouchDispatcher, ccTouchBegan are never called

onEnterTransitionDidFinish, onEnter, registerWithTouchDispatcher, ccTouchBegan are never called
0.0 0


I am a beginner with Cocos2dx but I have C++ experience and I managed to build quite a nice game so far. However, now I want to make it for mobile devices (without keyboard) and so I added a Joystick.

To keep this example basic, I have a Stage class extends CCLayer which has the autogenerated base code for initializing a scene. This scene works fine; it has the Stage layer as child, which has has images, sprites etc. As children of the Stage layer are also CCMenuItem buttons which are meant to beat the crap out of the enemies on screen. This is working fine as well.

Now, to keep stuff clean, I created a 1 to 1 translation of this Joystick which I used before in Cocos2d (ObjC). However now things starting to break down; Joystick extends CCLayer and I’m overriding:

virtual void onEnter();
virtual void onEnterTransitionDidFinish();
virtual void registerWithTouchDispatcher();
virtual bool ccTouchBegan(CCTouch pTouch, CCEventpEvent);
virtual void ccTouchMoved(CCTouch pTouch, CCEventpEvent);
virtual void ccTouchEnded(CCTouch pTouch, CCEventpEvent);
virtual void ccTouchCancelled(CCTouch pTouch, CCEventpEvent);

When initializing the Joystick, I call

And I add the Joystick to the Stage layer scene~~>(Stage*)layer->(Joystick*)joystick as structure. None of the overridden methods ever get called, so no touches are registered and nothing is working basically. What could be the reason for this as I cannot figure it out at all… I tried other Joystick code as well; same issue. So I’m doing something fundamentally wrong with Cocos2dx I feel, but I have no clue what. Who can help?


That looks alright to me… I do a similar thing and it’s all working fine. The only difference is I’m using

virtual void ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);

…instead of…

virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);

I don’t know if that makes any difference, but it might be a good place to start…



I think that the difference between those two methods (ccTouchEnded vs. ccTouchesEnded) is that one is for multi-touch and one is for single.