0

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!

Hailei
  • 42,163
  • 6
  • 44
  • 69
Agustin
  • 163
  • 2
  • 9

3 Answers3

1

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;
}
Hailei
  • 42,163
  • 6
  • 44
  • 69
mweathers
  • 941
  • 8
  • 11
1

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];

Emmy
  • 3,949
  • 5
  • 28
  • 30
0

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

Hailei
  • 42,163
  • 6
  • 44
  • 69
Anselm Scholz
  • 478
  • 9
  • 20