iosios7sprite-kitsksceneskview

How to dismiss SKScene?


When Im finished with my SKScene is there a way to dismiss the SKScene from within my SKScene class?

If not back in my Viewcontroller where I present my SKScene [skView presentScene:theScene]; is there a way to restart the scene or remove in from my SKView?

The SKScene Class Reference and SKView Class Reference are no help.

Update:

The following code removes my scene from my SKView [yourSKView presentScene:nil]; but when Im back in my view controller the scene is still running in the background. I can always pause it when the game is over and I'm sent back to my view controller(menu) but I'm wondering is there another method other then pausing it like completely removing it?

-(void)endTheGame {
    [highscoreLabel removeFromSuperview];
    NSLog(@"Game Over");
   //would like to end here before calling the below method in my view controller
    [self.delegate mySceneDidFinish:self];
}

Solution

  • "You can't go "Back to the View Controller" from a scene. The scene is a View, the view controller controls and displays views. Use the view controller to change views. Remember the view controller itself is not a view." -Wharbio

    Best solution here is to create another View Controller. This view controller will be my menu. Then the other viewcontroller will act as a host for the skscene.

    In my situation I then use my menu viewcontroller to dismiss the viewcontroller displaying in the skview.