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 http://brenwill.com/2010/cocos2d-ui-controls/#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?