Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runnables redirected to another node always complete instantly #1

Open
coughski opened this issue May 4, 2022 · 0 comments
Open

Runnables redirected to another node always complete instantly #1

coughski opened this issue May 4, 2022 · 0 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@coughski
Copy link
Owner

coughski commented May 4, 2022

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)
  }
}
@coughski coughski added the invalid This doesn't seem right label May 4, 2022
@coughski coughski self-assigned this May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant