Reputation: 225
I need to show ccscene on game pause. But it should be transparent. Can anyone please help me with this??
Thank you,
Anks
Upvotes: 4
Views: 3851
Reputation: 31
I know you already have an answer, but wanted to share my solution because I hit this link when researching the same issue. I also posted this in the cocos2d forums.
- (void)pauseSchedulerAndActionsRecursive:(CCNode *)node {
[node pauseSchedulerAndActions];
for (CCNode *child in [node children]) {
[self pauseSchedulerAndActionsRecursive:child];
}
}
- (void)resumeSchedulerAndActionsRecursive:(CCNode *)node {
[node resumeSchedulerAndActions];
for (CCNode *child in [node children]) {
[self resumeSchedulerAndActionsRecursive:child];
}
}
I have one scene and two layers, a stage/gameplay layer and a menu layer. My menus animate in and out, and I wanted my pause menu to be able to animate in and out as well. So I just added the above functions to my stage/gameplay layer. Then when the user hits pause, I call pauseSchedulerAndActionsRecursive: on my stage/gameplay layer and add my menu layer to the scene on top. My menu swallows all the touches, so touching is also disabled on the stage/gameplay layer while the menu layer is up. Then just call resumeSchedulerAndActionsRecursive: method to resume. Hope this helps someone out.
Upvotes: 2