Reputation: 13
Can someone please help me? I really want to add interstitial ads to my spritekit game but have no clue. I have tried a lot of tutorials and even google firebase but i cant seem to get to work.
Upvotes: 0
Views: 402
Reputation: 533
AdMob presents interstitial ads using view controllers and you can't present view controllers using SpriteKit. You'll need to use UIKit to present the interstitial ad. How you connect your SpriteKit and UIKit code is up to you, I'd either use delegation or a callback.
Delegation
protocol MyGameSceneDelegate: class {
func gameDidFinish()
}
class MyGameScene: SKScene {
weak var gameDelegate: MyGameSceneDelegate?
func finishGame() {
self.gameDelegate?.gameDidFinish()
}
}
Callback
class MyGameScene: SKScene {
var gameDidFinish: (() -> Void)?
func finishGame() {
self.gameDidFinish?()
}
}
If you're not familiar with these terms I highly recommend learning about common design patterns in Swift (or Objective-C). Apple has some great resources for both languages and there are tons of books that will help you get started with iOS development.
Upvotes: 1