Another way to do it, if you're not keeping track of different scenes and layers through a central singleton, is to pass along the gamescene object when you init the pause layer. And to make it proper, reusable and easy for you or others to understand later, you can make a delegate protocol and make whatever scene wants to use a pause layer conform to that protocol. Like so:
@protocol PauseLayerDelegate
- (void)resume
- (void)restart
- (void)exitToMenu // for example! if you want more than just resume functionality
@end
@interface PauseLayer : CCLayer {
id delegate;
// add other ivars you need here
}
@property (nonatomic, assign) id delegate;
// more properties
- (id) initWithDelegate:(id)theDelegate;
// more methods...
@end
@implementation PauseLayer
@synthesize delegate;
- (id) initWithDelegate:(id)theDelegate {
if ( (self = [super init]) ) {
self.delegate = <PauseLayerDelegate>theDelegate;
// other init stuff...
}
return self;
}
// other method implementations...
@end
In your GameScene, you then add the protocol and when initializing the PauseLayer, pass "self" as the delegate. Of course, you have to implement the resume method (and "restart", "exitToMenu" or whatever other methods you've declared) too. The nice thing about using this approach is that if you add other scenes (or even reuse the PauseLayer class in another project), you can use a different implementation of resume and the other protocol methods to do different things as needed.