O'Reilly logo

Learning iOS 8 Game Development Using Swift by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finishing the game loop

Move back to the SceneKit class and import SpriteKit at the top of the class as follows:

import UIKit
import SceneKit
import SpriteKit

Also, create a global variable called skScene of type OverlaySKScene. Add a new function called addSpriteKitOverlay and add the following code in the SceneKit class:

func addSpriteKitOverlay(){
        
    skScene = OverlaySKScene(size: _size, gameScene: self)
    scnView.overlaySKScene = skScene
    skScene.scaleMode = SKSceneScaleMode.ResizeFill
        
}

Here we initialize the skScene global variable we created earlier and pass in the size of the current scene and the current SceneKit class. Next we assign the skScene class to the overlaySKScene property of scnView. Finally, we set the scaleMode of the skScene variable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required