I have set my gravity so that at the start of my game the objects fall quite slow and as the player collects these items i want the gravity to increase.
override func didMove(to view: SKView) {
self.physicsWorld.gravity = CGVector(dx: 0.0, dy: -3.0)
initializeGame()
}
I have set the gravity like so but i am unsure on how to edit it with an if statement. E.g. if score = 20 gravity increases. any help would be great on how to properly do this
You might want to look through a SpriteKit tutorial. Generally, updating properties happens in the
update(_ currentTime: TimeInterval)method. You can implement this method in your SKScene subclass: