September 2018
Intermediate to advanced
434 pages
8h 47m
English
First, we need to keep track of how far the player has flown. We will use this later as well, for keeping track of a high score. This is easy to implement. Follow these steps to track how far the player has flown:
GameScene.swift file, add two new properties to the GameScene class:let initialPlayerPosition = CGPoint(x: 150, y: 250) var playerProgress = CGFloat()
didMove function, update the line that positions the player to use the new initialPlayerPosition constant instead of the old hardcoded value:// Add the player to the scene: player.position = initialPlayerPosition
didSimulatePhysics function, update the new playerProgress property with the player's new distance:// Keep track of how far ...
Read now
Unlock full access