单击iAds时暂停SpriteKit场景 [英] Pause SpriteKit Scene When Clicking on iAds
问题描述
我正在开发一个 SpriteKit
项目,当点击iAd时我很难暂停游戏,并在 iAd <时取消暂停/ code>被驳回。主要问题是从ViewController暂停Scene,我知道如果我想从
Scene.m
暂停场景我应该使用代码
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;
但是此代码在ViewController中不起作用。
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.
推荐答案
如果您有一个呈现场景的SKView,您可以从其ViewController中调用暂停像这样:
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
这篇关于单击iAds时暂停SpriteKit场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!