GameViewController button implement method in GameScene

I created a button in GameViewController, pause button, to pause the game. I wrote a void method in GameScene, -(void) stop. So that when I click the button, the app implement -(void)stop

//GameScene
-(void)stop{
...//code to stop the game
}

//GameViewController
-(IBAction)pause:(id):sender{
GameScene *gameScene = [[GameScene alloc] init];
[gameScene stop];
}

When I click the button, the character is still running. Please help. Thanks

Replies

I've also tried in this way

//GameScene.h
@property (strong, nonatomic) GameScene *gameScene;

//GameScene.m
-(void)***{
_gameScene = [[GameScene alloc] init];
}

-(IBAction)pause:(id)sender{
[gameScene pause]; //'pause' in this line is a void method in GameScene to make the game pause
}

But also don't help. Please help. Thank you

Anyone please help? Thanks

I tried this code.

@interface XXXViewController ()
@property (strong, nonatomic) YYYViewController *y;
@end

-(void)zzz{
_y = [[YYYViewController alloc] initWithNibName:nil bundle:nil];
[_y aMethodInYYYViewController];
}

It worked for me. But I can't use initWithNibName for GameScene. If I just use init. It won't work. Please help. Thanks