I have an IF statement and I need it to trigger when the score >= 200 but only happen once and not repeatedly.
Here's my code:
if score >= 200 {
meteRedTimer.invalidate()
meteBlueTimer = Timer.scheduledTimer(timeInterval: 0.7, target: self, selector: #selector(self.makeBlueMete), userInfo: nil, repeats: true)
} else {
}
However this constantly starts the timer all the time when the score is => 200 and not just one timer which I understand.
If I do score = 200 this would work however there is a chance the score could jump from 190 to 210 for example depending on the game play.
How could I basically stop this IF statement once it has been triggered once?
Aucun commentaire:
Enregistrer un commentaire