Steal touches from every TouchDelegates but children ones

Steal touches from every TouchDelegates but children ones
0.0 0


I would like to create some kind of popup for my App. By Popup I mean a layer displayed above every other, and that captures every touch event. But I also want it to transmit touches event to its children, in case it contains menu items or buttons.
Playing with touch priorities doesn’t seem to be enough in a case like this one :

  + CCLayer 
  |+ CCMenu
  + Popup
  | + CCMenu

If Popup priority is above kCCMenuHandlerPriority, the other layer menu will still catch touches even if the popup is displayed. If popup priority is below kCCMenuHandlerPriority, the other layer menu won’t catch touches, but neither the popup menu.
Does cocos2d-x provides a simple way to do what I’d like to ?
Thanks in advance for your help


So you want to disable touch on the CCLayer when you have the Popup layer visible?

You can use *CCMenu::setEnabled( bool )* before showing the pop up. Then re-enable it when you destroy the popup.


This is what I do for the moment but I’m looking for a generic way to do this.
The code gets a lot more complex when menu is nested in sub childs.


I guess that’s the only way now. Apparently, there is no *CCLayer::setEnabled( bool )* that automatically disables the whole layer.


void CCLayer::setTouchEnabled (bool value) exists… but im not sure if it disables the touch on menu associated with the layer…


Menus have a world of their own. Even disabling touches on the layer will still enable touches on the menu.