简体   繁体   中英

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()

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

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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