If adding UIView A as a child of another UIView B, B won't receive touches within A's bounds. How can I achieve the same effect in cocos2d? I use a CCMenu added to the CCLayer, but sometimes want to add a semitransparent overlay (this time covering all of the CCLayer). In the overlay I use other buttons (CCMenu etc). In this scenario I don't want to allow touches to go through to the background layer. How do I stop this? Using cocos2d iphone v2.1.
Asked
Active
Viewed 112 times
0
-
I think I got how to get around this: http://stackoverflow.com/a/12458981/129202 cclayer needs to have a lower .touchPriority than CCMenu, which has `kCCMenuHandlerPriority`. So I create a CCLayerColor and set its touchPriority to kCCMenuHandlerPriority - 1. Any CCMenu added to the blocking layer will have even lower priority. – Jonny May 31 '13 at 04:04
-
Thats how I did it in my game. You will have to subclass the CCMenu that you add to your layer to register with a lower priority than your semitransparent layer, it doesn't do it automatically I don't think. – Marcus Schwab Jun 02 '13 at 03:49
-
I haven't still found a 100% solid way to do this. It gets out of hand when using popup layers, and then popups on top of those, and so on. Several generations of cocos2d, each with slightly different take on touch handling, add to the confusion. A rock solid easy class is needed for this. I don't have time to try to figure that out :-( – Jonny Jul 18 '13 at 08:41