简体   繁体   English

点击iAd时暂停SpriteKit场景

[英]Pause SpriteKit Scene When Clicking on iAds

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. 我正在开发SpriteKit项目,并且在单击iAd时要暂停游戏,而在关闭iAd时要暂停游戏。 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 主要问题是从ViewController暂停场景,我知道如果我想从Scene.m暂停场景,我应该使用代码

    self.scene.view.paused = YES;

however this code doesn't work in the ViewController. 但是此代码在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. 任何帮助表示赞赏,谢谢。

If you have an SKView that's presenting a scene, you can call pause from within its ViewController like this: 如果您有一个呈现场景的SKView,则可以从其ViewController中调用stop,如下所示:

Objective-C: 目标C:

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

Swift 迅速

let skView: SKView = self.view as! SKView
skView.scene.paused = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM