I need to know when an SKAudioNode has finished, but using the SKAction(:completion:) doesn't seem to work:
audioNode.run(SKAction.play()) {
// do something after it has finished
}
The sound plays fine, but the thing that is supposed to execute on completion actually runs immediately.
Can someone please let me know what I´m doing wrong, and, if possible, how can I fix this?
Thank you
One possible work-around is to force a delay. Although it works, it´s far from perfect:
let sequence = SKAction.sequence( [SKAction.play(), SKAction.wait(forDuration: soundDuration ) ])
audioNode.run(sequence, completion: {
audioNode.removeFromParent()
})