Reputation: 173
I'm handling the touches manualy through a class that holds every touchable sprite. Also, every menu is a CCLayer
, and when I change from one menu to the other, I use the CCTransition###
and get the new scene.
So, the layers are "still there" and when I touch one menu, the previous layer also receive it... like when I start the game in a new CCLayer
, and then the menus are still affected for the multi touch...
If I use single touch, I can swallow the touches, but the game must have multi touch...
What can I do? Thank you all!
Upvotes: 0
Views: 1850
Reputation: 3999
You can set up the priority to 0 for the top layer and priority to 1 for the layer under it like this.
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
Upvotes: 1
Reputation: 478
You could try to use the property
self.isTouchEnabled = NO;
within the layer, you don't want to receive touches.
If you you use CCButton
objects you need to disable them.
I hope it helps...
Greetings Anselm
Upvotes: 0
Reputation: 951
You need to consume the touch event in whatever layer needs it. After a layer consumes it, the touch will no longer be propagated to "previous" layers.
http://www.cocos2d-iphone.org/api-ref/0.9.0-beta/_c_c_touch_delegate_protocol_8h_source.html
To consume a touch event, you return YES in the ccTouchBegan
delegate method.
EDIT: changed method name to match CCStandardTouchDelegate
- (BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
if (condition)
return YES;
else
return NO;
}
Upvotes: 1