I'm trying to implement a system so that my main CCLayer can have other "modal" layers stacked on top of it (similar to modal dialogs), which would disable touches from propagating down to any lower layer in the stack until the topmost layer is dismissed.
So far, I can think of a few ways to do this, but none are very appealing:
1. Either I have to keep track of the modal-stack-depth, and then make sure any touch delegate added to a modal layer uses a priority which will trump any delegates prioritized on the lower layers. This is, of course, very unclean and wouldn't work with the current CCMenu implementation (it would have to be subclassed to handle dynamic priorities).
2. Or I simply keep a list of all touch delegates added for each modal layer, and then add/remove them accordingly from the touch manager each time the modal stack changes. This is also a pain in the neck, and would probably require some poking around in the touch manager.
3. A final method would be of course to just write all my own components and make sure the modal CCLayer classes are the only nodes that receive touches (which they will then propagate to their custom child components). Then I could just add/remove the modal layers from the touch manager when the modal stack changes, which would be less of a headache.
Has anyone else tackled this problem? Or do most people just avoid having modal dialogs in their games? Well, any thoughts are welcome.