Приведенный ниже код запускает анимацию и после завершения запускает функцию resetBall.
Почему строка (ball.texture = normalTexture) не работает? (добавление себя перед ним не решает проблему)
Любая помощь будет принята с благодарностью!
func resetBall() {
ballDying = false
let normalTexture = SKTexture(imageNamed: "Ball1")
ball.texture = normalTexture
self.ball.position = CGPoint(x: -120, y: 40)
}
var ballDying = false
override func update(_ currentTime: TimeInterval) {
if ((map_1_buffer.contains(ball.position)) == false) && !ballDying {
ballDying = true
let texture1 = SKTexture(imageNamed: "death_1")
let texture2 = SKTexture(imageNamed: "death_2")
let texture3 = SKTexture(imageNamed: "death_3")
let deathAnimation = SKAction.animate(with: [texture1, texture2, texture3], timePerFrame: 1)
self.ball.run(deathAnimation, completion: resetBall)
}
}