iAd banner unpauses spritekit game

蹲街弑〆低调 提交于 2020-01-17 04:23:07

问题


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) I have several objects in my game that have a sequence (in series not parallel) of SKActions.

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) 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 appears lalala... everything is paused as it should be. NSLog statement in "Note" below not displayed.

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 called c) 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...)

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");
}

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!


回答1:


just try this one

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


来源:https://stackoverflow.com/questions/29314195/iad-banner-unpauses-spritekit-game

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!