-
Notifications
You must be signed in to change notification settings - Fork 0
Description
In the following example, a sequence of runnables is set to run on firstNode: the 1 second duration Fade runnable is redirected to run on secondNode, and then the 1 second duration Scale runnable runs on firstNode.
It would be reasonable to expect that secondNode will fade out over 1 second, and afterwards, firstNode will double in size over 1 second, and that the entire sequence should take 2 seconds total to run.
But that is not how the .changeTarget(to:) modifier currently behaves. Once the fade is redirected to secondNode and begins to execute, that step in the sequence is considered to be complete, and the scale on firstNode will begin, so the 2 nodes will end up animating at the same time. The total duration of the sequence will be around 1 second.
I think the first behavior should be implemented because it simplifies the coordination of animations across multiple nodes. A workaround is to keep nesting redirections, shown in the second block of code, but this is both harder to write and read.
let firstNode = SKNode()
let secondNode = SKNode()
firstNode.run {
Sequence {
Fade.out(over: 1)
.changeTarget(to: secondNode)
Scale(to: 2, over: 1)
}
}Convoluted workaround to implement expected behavior:
firstNode.run {
Sequence {
Sequence {
Fade.out(over: 1)
Scale(to: 2, over: 1)
.changeTarget(to: firstNode)
}
.changeTarget(to: secondNode)
}
}