我正试图首次在我的手机游戏中实施admob插页式广告。我设置了一切,它的工作原理。但出于某种原因,广告没有利用整个屏幕空间。
看起来像这样
GameViewController
var interstitial: GADInterstitial!
override func viewDidLoad() {
super.viewDidLoad()
loadInterstialAds()
NotificationCenter.default.addObserver(self, selector: #selector(notificationReceived2(_:)), name: NSNotification.Name(rawValue: "showAds"), object: nil)
let filePath = Bundle.main.path(forResource: "background_Music", ofType: "wav")
let audioNSURL = NSURL(fileURLWithPath: filePath!)
do { backendAudio = try AVAudioPlayer(contentsOf: audioNSURL as URL)
} catch { print("error background") }
backendAudio.numberOfLoops = -1
backendAudio.volume = 8
backendAudio.play()
let scene = MainMenuScene(size: CGSize(width: 1536, height: 2048))
scene.scaleMode = .aspectFill
// Present the scene
if let view = self.view as! SKView? {
view.presentScene(scene)
view.ignoresSiblingOrder = true
view.showsFPS = false
view.showsNodeCount = false
}
}
func loadInterstialAds(){
interstitial = GADInterstitial(adUnitID: "ca-app-pub-70675555555551199/5275555553")
let request = GADRequest()
interstitial.load(request)
}
func showInterstialAds() {
if interstitial.isReady {
interstitial.present(fromRootViewController: self)
} else {
print("Ad wasn't ready")
}
}
@objc func notificationReceived2(_ notification: NSNotification) {
if let message = notification.userInfo?["message"] as? adTypes {
if message == .interstitial {
showInterstialAds();
} else if message == .loadInterstitial {
loadInterstialAds()
}
}
}
我正在发送广播以显示来自我的 GameOverScene:SKScene
的广告有人可以帮我解决这个问题