iAd横幅取消暂停Spritekit游戏

iAd横幅取消暂停Spritekit游戏

本文介绍了iAd横幅取消暂停Spritekit游戏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有iAd标语的sprite套件开发iOS游戏,并且此iAd导致游戏自行取消暂停,并且通过取消暂停我的意思是SKActions仍在继续,以下是一些详细信息:

I am developing an iOS game using sprite kit with an iAd banner, and this iAd is causing the game to unpause itself, and by unpausing I mean SKActions are continuing, here are some details:

1)我的游戏中有多个对象,这些对象具有一系列(而非并行的)SKAction.

1) I have several objects in my game that have a sequence (in series not parallel) of SKActions.

2)单击游戏屏幕上的暂停游戏"按钮,恢复"工作正常-一切都按需要暂停.下方注释"中的NSLog语句未显示.

2) clicking the 'pause game' button on my game's screen and 'resuming' work fine - everything is pauses as desired. NSLog statement in "Note" below not displayed.

3)我编写了以下通知,其中包含一个观察者,该观察者调用选择器暂停游戏(正确调用该游戏).下方注释"中的NSLog语句未显示.

3) I've coded the following notification which has an observer that calls a selector to pause the game (which gets called properly). NSLog statement in "Note" below not displayed.

-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
    [[NSNotificationCenter defaultCenter] postNotificationName:@"iAdsoPauseGame" object:self];
    return YES;
}

4)iAd出现了lalala ...一切都应该暂停.下方注释"中的NSLog语句未显示.

4) iAd appears lalala... everything is paused as it should be. NSLog statement in "Note" below not displayed.

5)当我在iAd中单击"x"时,将按以下顺序进行操作:a)当我通过转到iAd暂停"游戏时,我的游戏对象正在运行的SKAction已完成,并且列出了NSLog语句(在下面的注释中).b)大约0.5秒后,我的ViewController的"viewDidAppear"被调用c)5b之后不到1毫秒,我的iAd的"bannerViewActionDidFinish"被调用(我在这里收到一条通知,告知我的游戏暂停...问题是我关闭iAd与调用此方法之间存在0.5秒的停机时间. )

5) when I click the "x" in the iAd, the following occur in this order:a) the SKAction that my object in game was running while I 'paused' the game by going to iAd goes to completion, and the NSLog statement (in Note below) IS listed.b) around 0.5sec later, my ViewController's "viewDidAppear" is calledc) less than 1ms after 5b, my iAd's "bannerViewActionDidFinish" is called (I have a notification here that tells my game to pause ... problem is there is this 0.5sec downtime between me closing the iAd and this method being called...)

注意:在游戏的主.m文件中,在更新"方法(称为每一帧")中,我有一个NSLog语句(如下),并且在我点击iAd中的"x"后便会立即显示,然后停止(调用5b/5c时).

Note: In my game's main .m file, in the "update" method (called every frame), I have an NSLog statement (below), and this does display as soon as I click the 'x' in the iAd, but then stops (when 5b/5c are called).

if (NodeGamePlay.paused==FALSE) {
    NSLog(@"NodeGamePlay.paused==FALSE");
}

所以我的问题是:退出iAd时,如何防止SKaction继续(步骤5a中发生)?谢谢您的时间和帮助-这已经困扰了我很长时间了!

So my question: How can I prevent the SKaction from continuing (step that occurs in 5a) when I exit the iAd? Thank you for your time and help - this has been bugging me for quite some time!

推荐答案

只需尝试一下

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
     skView.scene.paused = YES;
     return true;
}

这篇关于iAd横幅取消暂停Spritekit游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 09:08