How to pop to rootViewController from SKScene?
im trying to build a game with menu screen. There are two scenes - one for menu and one for game.
I have problem with jumping to rootView from a game scene. Game scene has SKScene with menu button - SKLabelNode. When touched it should move player to menu screen.
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
SKNode *touched = [self nodeAtPoint:[touch locationInNode:self]];
if ([touched.name isEqualToString:BUTTON_MENU_NAME]) {
UIViewController *vc = self.view.window.rootViewController;
[vc.navigationController popToRootViewControllerAnimated:YES];
}
}
Touch is detected correctly but nothing happens.