I have an animation running with SKAction.repeatForever
animation loop, which runs an animation all over again for indefinite amount of time.
node.run(SKAction.repeatForever(
SKAction.animate(with: animationFrames,
timePerFrame: timePerFrame,
resize: true,
restore: true)))
I have a user-triggered (with a touch) animation that I want to fire after the currently animated loop finishes. How can I catch when the current loop of SKAction.animate
finishes and then stop, remove and replace the animation with a second one?
|--Loop1--|--Loop2--|--Loop3--|--...
| user trigger here
| wait until Loop2 finishes and then replace the animation
Pseudo code of what kind of functionality I'm looking for:
... somewhere else ... {
animatedNode.run(SKAction.repeatForever(SKAction.animate(...)))
}
func onTouch() {
foreverRunningAnimation.waitUntilLoopFinishes() {
animatedNode.removeAllActions()
animatedNode.run(SKAction.repeatForever(SKAction.animate(< second animation>)))
}
}