我正在游戏中实施横幅广告。在@erdekhayser的帮助下,横幅显示成功。但是当我点击横幅时,游戏不会停顿。 代码如下所示:
import UIKit
import SpriteKit
import iAd
import Foundation
class GameViewController: UIViewController, ADBannerViewDelegate{
var gameScene = GameScene()
var adBannerView = ADBannerView(frame: CGRect.zeroRect)
func loadAds() {
adBannerView.center = CGPoint(x: adBannerView.center.x, y: view.bounds.size.height - adBannerView.frame.size.height / 2)
adBannerView.delegate = self
view.addSubview(adBannerView)
}
//iAd bannerView
func bannerViewWillLoadAd(banner: ADBannerView!) {
}
func bannerViewDidLoadAd(banner: ADBannerView!){
loadAds()
println("1")
adBannerView.hidden = false //now show banner as ad is loaded
}
func bannerViewActionDidFinish(banner: ADBannerView!) {
println("2")
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
//Tap to view the ad
gameScene.paused = true
println("3")
return true
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
adBannerView.hidden = true
println("44444")
}
// iAd stopped here ///////////
}
有人帮我解决了吗?
答案 0 :(得分:0)
if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
// Configure the view.
let skView = self.view as SKView
skView.paused = true
}
bannerViewActionShouldBegin
方法中的。 添加工作。