因此,我用于显示插页式 iAd 的代码有效,但加载广告的速度很慢。当用户在我的 GameOver 场景中并点击重试时,它会进行随机数检查,如果该数字与我所说的匹配,它会使用 NSNotificationCenter 加载我的插页式 iAd。
func interstitialAdChecker(){
var randomAd = Int(arc4random() % 3)
println(randomAd)
if randomAd == 1 {
NSNotificationCenter.defaultCenter().postNotificationName("showInterstitialAdsID", object: nil)
}
}
在我的游戏结束场景中,当用户点击重播时,这是转换场景的代码:
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
if self.nodeAtPoint(location) == self.replayButton {
gameOverLogo.removeFromParent()
replayButton.removeFromParent()
yourScore.removeFromParent()
highScore.removeFromParent()
rateButton.removeFromParent()
scoreBackground.removeFromParent()
interstitialAdChecker()
var scene = InstructionScene(size: self.size)
let skView = view as SKView!
skView.ignoresSiblingOrder = true
scene.anchorPoint = CGPoint(x: 0.5, y: 0.5)
scene.scaleMode = .ResizeFill
scene.size = skView.bounds.size
skView.presentScene(scene, transition: transition)
}
}
}
在加载 InstructionScene 和显示 Interstitial iAd 之间有 1 - 3 秒的延迟,所以有人知道如何在用户点击重试时使其从底部无缝向上滑动吗? 1 - 3 秒的延迟意味着用户可能会启动游戏并在游戏过程中弹出广告,这并不好。谢谢!
最佳答案
您是使用模拟器还是实际设备进行测试?根据我的经验,如果您使用的是模拟器,则可能会延迟显示广告。
如果您正在您的设备上进行测试,那么您应该尝试延迟场景转换,直到用户处理了 insterstitialAd。您可以为广告显示时间设置一个 bool 值,这样您就不会转换。然后,当用户取消广告时,就会发生转换。
关于swift - 如何在 Swift 中无缝过渡到 Interstitial iAd?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27910774/