我想知道如何在展示我的GameOverScene时设置Admob插页式广告.我有什么办法只在游戏结束时才展示广告?我如何在Swift中实现它?
我是指这篇文章如何使用swift,spritekit和xcode调用admob interstitial广告?但我想知道如何在场景之间调用广告.
编辑 以下是我用来展示广告的代码
class GameViewController: UIViewController, GADInterstitialDelegate {
var interstitial = GADInterstitial()
var intersitialRecievedAd = false
let defaults = NSUserDefaults.standardUserDefaults()
override func viewDidLoad() {
super.viewDidLoad()
interstitial.delegate = self
self.interstitial = createAndLoadAd()
let timer = NSTimer.scheduledTimerWithTimeInterval(0.5, target: self, selector: "checkIfAdIsToBeDisplayed:", userInfo: nil, repeats: true)
//Scene implementation, boring stuff, got nothing to do with the ads...
...
}
func checkIfAdIsToBeDisplayed(timer:NSTimer) {
if defaults.boolForKey("adToBeShown") == true && intersitialRecievedAd == true {
showInterstitial()
defaults.setBool(false, forKey: "adToBeShown")
intersitialRecievedAd = false
} …Run Code Online (Sandbox Code Playgroud) 我希望我的节点以正弦曲线波形运行,我尝试将其用于CGPath.如何创建遵循正弦曲线的CGPath?除了手动找到曲线上的点之外还有其他方法,还是我可以传入正弦函数?
let action = SKAction.followPath(<the sine path>, asOffset: true, orientToPath: true, duration: 5)
这可以通过Bezier Paths完成,然后转换成CGPaths吗?谢谢.