Search code examples
swiftpropertiessprite-kitoperatorsios9

Depreciation ++ operator in Swift 3, Looking for a work around


I currently use this as a game over counter.. GameScene Swift

var gameOverCounter = 0

it is called when a player runs hits an enemy (no physics bodies involved) touches began method

gameOverCounter++
if gameOverCounter > 3 {
    numRounds = 121
    // ...
}

same for number of rounds, and I am sure theres is plenty of people that use it for scoring...

score++

just curious for work arounds in relation to the topic, or if theres a better way to populate incremental value of there properties and achieve the same behavior.


Solution

  • i += 1
    

    Is the same as

    i++
    

    But it's more explicit and obvious