objective-ccocos2d-iphoneccmenuitem

disable touches behind a sprite


I have a menu in my app, with clickable buttons using CCMenuItemImage. When you press one of the buttons, for example buy button it spawns anther image on top of everything, a confirmation screen(do you really want to buy this item). This screen is placed on z:100 just to be sure it is on top of everything.

The problem is the buttons on the menu below(buy, back, next(all CCMenuItemImage)) are still clickable. I had the idea to just use [button setIsEnabled:NO]; but this doesn't seem to work unless the CCMenuItemImage has a disabledImage set, but some of my buttons (next, previous) use the disabledImage and it looks silly to make the buttons disabled when this confirmation screens shows up.

Is there a way to just disable all the touches to the buttons below and only allow the confirm screen to take touches?


Solution

  • Set the enabled property of the CCMenu to NO. If that doesn't work without disabled images simply set the CCMenu visible property to NO. This also disables the menu reacting to touches.