Pregunta

I am working on a SpriteKit project and I'm struggling to pause the game when the iAd is clicked, and unpause when the iAd is dismissed. The main problem is pausing the Scene from the ViewController, I know that if I want to pause the Scene from the Scene.m I should use the code

    self.scene.view.paused = YES;

however this code doesn't work in the ViewController.

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
//pause game
}

- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
//unpause game
}

I know that I would like to pause the game in the section above but I'm having trouble finding the resources to know how to perform this. Any help is appreciated, thanks.

¿Fue útil?

Solución

If you have an SKView that's presenting a scene, you can call pause from within its ViewController like this:

Objective-C:

SKView *skView = (SKView *)self.view;
skView.scene.paused = YES;

Swift

let skView: SKView = self.view as! SKView
skView.scene.paused = true
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top