0

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?

Clev3r
  • 1,568
  • 1
  • 15
  • 28

2 Answers2

1

Did you override any of the on* methods like onEnter, onExit, etc. in any of your classes?

If so, you must call the super implementation (ie [super onEnter]) in each, otherwise some cocos2d functionality like scheduling or input may stop working.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • That's what I checked initially, but I don't override any onEnters. – Clev3r Feb 18 '13 at 21:12
  • It's really strange. The menu items don't register any taps, but swipes/pans/multi-touch works perfectly. – Clev3r Feb 18 '13 at 21:56
  • The other cause might be that your scene is leaking. Set a breakpoint in dealloc of the scene, if it never triggers your old scene is still in memory, possibly causing all kinds of weird behavior. – CodeSmile Feb 18 '13 at 22:52
  • I tried that as well. As soon as I leave the scene to go to the Game the Menu's dealloc is called. – Clev3r Feb 19 '13 at 00:12
  • I cant figure it out and it's driving me crazy. Might it be some sort of interference with Kobold2d's KKInput? I wouldn't think so... as I'm not even using KKInput in the menu, but instead ccmenu's build in touch handling. – Clev3r Feb 19 '13 at 01:10
  • Ah! By adding KKInput to another layer that also isn't using it, I could replicate the same issue. Any suggestions? It seems kkinput is overriding the touch receiving @LearnCocos2D? – Clev3r Feb 19 '13 at 01:21
1

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.

Clev3r
  • 1,568
  • 1
  • 15
  • 28