coding22 coding22 - 9 months ago 18
Swift Question

How do I increment the score by 10 when a user collects a coin in Swift?

Right now its going up by 1 but I need it to go up by 10 whenever a coin is collected. How do I do that? I tried doing it this way self.score + 10
but that didn't work. Thanks! If you need more code or info let me know!!

if firstBody.categoryBitMask == HeroCategory && sixthBody.categoryBitMask == CoinCategory {



To increment a value by 10, use:

self.score += 10

See the documentation for Compound Assignment Operators for more information.