In my SpriteKit project I would like to toggle a variable for a second and then untoggle it, every 30 seconds:
This is how I handle the timer:
override func didMove(to view: SKView) {
DispatchQueue.main.asyncAfter(deadline: .now(), execute: {
self.myTimer()
})
}
func myTimer() {
run(.wait(forDuration: 1), completion: {
self.timer += 1
//This is how I use them after 30 seconds
self.timer > 29 ? self.goldBottle = true : nil
self.timer > 30 ? self.goldBottle = false : nil
self.myTimer()
})
}
What can I do? Any suggestion is appreciated