For showing scores and buttons for the game, we will add 2D SpriteKit layer. For adding the overlay, create a class called OverlaySKscene
. In this class, add the following:
import SpriteKit class OverlaySKScene: SKScene { let _gameScene: GameSCNScene! let myLabel: SKLabelNode! var gameOverLabel: SKLabelNode! var jumpBtn: SKSpriteNode! var playBtn: SKSpriteNode! required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } init(size: CGSize, gameScene: GameSCNScene){ super.init(size: size) } }
To import SpriteKit we will have to create a subclass of SpriteKit. Create global variables of type GameSCNScene
, SKLabelNodes
, and SpriteNodes
. Here we create two LabelNodes
: one for displaying score and the other to show "game over" text. We also create two spriteNodes
: one for the play button and the other for the jump button.
We add the required init
function and the default...