February 2017
Beginner to intermediate
258 pages
5h 31m
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: ...Read now
Unlock full access