Nouman Bhatti
Nouman Bhatti

Reputation: 1837

Disable layer touch in cocos2d

Adding another uppper layer in cocos2d still touchable background layer. How to disable background layer just like pause screen. Here is how i am trying to do:

GamePauseLayer *pGamePauseLayer = [GamePauseLayer node];
[self addChild:pGamePauseLayer z:50];

z is higher than previous layer and other UI components. Please suggest any solution.

Upvotes: 0

Views: 865

Answers (1)

Andrey Chernukha
Andrey Chernukha

Reputation: 21808

I think this should help. In your GamePauseLayer's onEnter method write the following:

[[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self priority:257 swallowsTouches:YES];

and in onExit:

[[[CCDirector sharedDirector] touchDispatcher] removeDelegate:self];

Upvotes: 1

Related Questions