I’m currently working on a menu using cocos2d-x (Android) and I’m facing this problem.
I would like to have a scrollable menu with big sprites (basically, you can see only one image and a half on the screen). I would like to scroll the menu by swiping (fling?) my finger on the screen, then select a menu item with a tap on the image.
So in my CCLayer I create a CCMenu and I add CCMenuItemImage to the menu.
virtual void ccTouchesMoved(NSSet *pTouches, UIEvent *pEvent); virtual void ccTouchesBegan(NSSet *pTouches, UIEvent *pEvent);
in my CCLayer and I handle the moved-began events to scroll the menu. However I have a problem, if you start to touch (touchesBegan) ON a menu item, that is you touch an image and then try to scroll left or right, the event is not propagated to the CCLayer. I think this is probably wanted by cocos2d-x authors.
However having a look at cocos2d for iphone API, the prototype for ccTouchesMoved or ccTouchesBegan returns a bool instead, and that bool is probably used to propagate the event (bubbling) to parents (so that you can overwrite ccTouchesMoved and return false if you want the event to be propagated). This doesn’t seem to be possible in cocos2d-x as the return type is void.
Did I get this wrong? What’s the correct way of achieving this menu scroll in cocos2d-x?