ioscocos2d-iphoneccmenuitem

Second time entering scene, input not accepted


I've found a peculiarity with Cocos2D and I cannot seem to fix it. From the AppDelegate I load into a Menu, which is a CCScene. The scene holds a CCLayer, which itself holds the CCMenu. Everything works find the first time through. After my game has ended, I bring the user to a GameOverScene and prompt them to return to the menu. I am reloading the menu scene and calling [[CCDirector sharedDirector] replaceScene:menu]. After entering this menu, though, not all input functions. I can no longer tap on menu items, but I can pan / multi-touch on them to trigger the item. What gives?

Is there some way on initialization to reset the CCScene to receive input, and if so, will this mess up CCMenu's input receiving?


Solution

  • I finally figured it out, and the answer was right under my nose. Earlier in my game development I needed a way to stop KKInput from swallowing gestures. I'm not entirely sure of the ramifications of this action, but I was able to do so like this:

    KKInput* input = [KKInput sharedInput];
    UITapGestureRecognizer* tapGestureRecognizer;
    tapGestureRecognizer = input.tapGestureRecognizer;
    tapGestureRecognizer.cancelsTouchesInView = NO
    

    It seems that the default Kobold2D behavior is to swallow all touches, which was preventing the CCMenu from receiving any tap gesture.