Interstitial ad with admob at gameOverScene

為{幸葍}努か 提交于 2019-12-23 04:29:10

问题


I have searched the internet high and low for direction regarding adding an interstitial admob ad at the game over scene with SpriteKit when using swift.

The google documentation still uses Obj-C.

What I have gathered so far is that I need to initialize the ad in the viewController and then call it from the game over scene?

Any advice would be greatly appreciated.


回答1:


Updated solution

I set in the view controller in the viewdidload

 NSNotificationCenter.defaultCenter().addObserver(self, selector:"loadAndShow", name: "loadAndShow", object: nil)

then I have a separate function (in the viewcontroller ) called loadAndShow ... which will load and show the interstitial ad if ready

then from the gameOverScene, I call

NSNotificationCenter.defaultCenter().postNotificationName("loadAndShow", object: nil)

which will run the function from the VC to present the ad. Works perfectly.



来源:https://stackoverflow.com/questions/30494495/interstitial-ad-with-admob-at-gameoverscene

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