Game Development Reference
In-Depth Information
Listing 15-8 . Update the overlaySKScene Parameter
if sceneView.touchCount > 0 && !gameStarted {
resetSpaceman()
sceneView.overlaySKScene = gameOverlay
gameOverlay.startTimer()
gameStarted = true
}
To restart the player, just touch anywhere on the screen in order to restart the game, as
shown in Figure 15-3 .
Figure 15-3 . “Game over” screen
Bonus Section
To make the game a bit more dynamic, it would be great if you had your obstacles and en-
emy randomly placed in the playing field. To do that, you need to create some methods
that will give you a random position. A good place to put these methods is the
SharedConstants.swift file. Open the SharedConstants.swift file to add a couple of im-
ports.
import UIKIt
import SceneKit
With these imports in place, you will be able to add the methods you will use to create the
random position, as in Listing 15-9 .
Search WWH ::




Custom Search