Reputation: 1019
I have two cclayers. The top cclayer has several objects (derived from ccnode) and is multitouch enabled. I use cctouchesbegan to detect touches on these objects. that all works fine.
but below the top cclayer I would like to have another multitouch enabled cclayer. so whenever an object is not touched on the top cclayer I'd like the bottom cclayer to react to the touches. the bottom cclayer is basically just a solid background and I want it to react when it's touched. right now both cclayers react to touches simultaneously.
I know that with single touches this is easy to solve with the touchdispatcher and setting a priority. but I'm stuck because it's important that both cclayers are multitouch enabled.
is there any solution to this?
Upvotes: 1
Views: 269
Reputation: 64477
Multiple touches: only enable touch input on the top layer. If top layer determines that a touch did not begin on one of the layer's sprites, it will simply call the same ccTouchesBegan method on the bottom layer. Same for all following events (moved, ended) of that specific touch.
Single touches: Return YES from ccTouchBegan whenever the layer handled the touch and the other layer shouldn't also process that touch.
Upvotes: 1