-
Book Overview & Buying
-
Table Of Contents
Swift Game Development - Third Edition
By :
In the GameSCNScene class, import SpriteKit at the top:
import UIKit
import SceneKit
import SpriteKit
Also create a global variable called skScene of type OverlaySKScene. Add the following code in the GameSCNScene at the end of the init function:
skScene = OverlaySKScene(size: _size, gameScene: self) scnView.overlaySKScene = skScene skScene.scaleMode = SKSceneScaleMode.Fill
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 to type SKSceneScaleMode.Fill.
Next, create a new function called heroJump as follows:
func heroJump(){
hero.jump()
}We call the jump function of the hero class here, which will get called whenever we press the jump button.
Next, we will still need to add the Boolean and functions to the class to make our game...