简体   繁体   English

在Swift(SpriteKit)中删除adBannerView

[英]Removing an adBannerView in Swift (SpriteKit)

When the user crashes and the game over code block is run the adBannerView appear at the top of the screen, when the user taps to play again it dissapears using the removeFromSuperView() 当用户崩溃并且游戏通过代码块运行时, adBannerView出现在屏幕顶部,当用户点击再次播放时,它使用removeFromSuperView()消失

However, if the user goes to the "Settings Scene" (ad banner view dissapears and when the settings scene loads it loads a new bannerView ect) but when i hit the "Play" Button (which takes the user back to the gameScene the adBannerview doesn't get removed 但是,如果用户进入“设置场景”(广告横幅视图消失,当设置场景加载时,它会加载新的bannerView等),但是当我点击“播放”按钮(将用户带回到gameScene adBannerview)不会被删除

In my game Scene: 在我的游戏场景中:

 override func didMoveToView(view: SKView) {
    /* Setup your scene here */

    adBannerView.removeFromSuperview()
 }

 contactBegins {
 //GameOver
 loadAds()
 }

// Pressed Settings Node 
adBannerView.removeFromSuperview()

In settings i have exactly the same setup then when the user presses "Play" it has removeFromSuperView but nothing gets removed when it transitions to the next scene... 在设置中,我有完全相同的设置,然后当用户按下“播放”时,它具有removeFromSuperView ,但当它转换到下一个场景时没有被删除...

When your move to the next scene just make the banner hidden like this: 当您移动到下一个场景时,只需将横幅隐藏为:

adBannerView.hidden = true

Also, look through your code and make sure you're not re-adding the banner in the game scene as that could be the problem too. 此外,查看您的代码并确保您不会在游戏场景中重新添加横幅,因为这也可能是问题所在。

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

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