0
votes

I'm trying to run an SKAction on 3 separate nodes at the exact same time. I have looked into SKAction.group but all I can find is in relation to running parallel SKActions on the same node, not on different nodes.

For example I need 3 SKSpriteNodes to move 150pt left at the exact same time, If I write this like:

nodeOne.run(SKAction.moveBy(x: 0-150, y: 0, duration: 0.25));
nodeTwo.run(SKAction.moveBy(x: 0-150, y: 0, duration: 0.25));
nodeThree.run(SKAction.moveBy(x: 0-150, y: 0, duration: 0.25));

The actions can be observed with the naked eye to not be parallel, with the later actions visibly lagging behind by what seems to be a few frames. Is it at all possible to run SKActions in parallel on separate nodes?

1

1 Answers

0
votes

The lag might be from creating the 3 separate SKActions, all of which are identical. Try creating a single ‘moveBy‘ SKAction in ‘didMove(to:)‘:

let moveAction = SKAction.moveBy(x: -150, y: 0, duration: 0.25))

and then running that action on the 3 nodes:

nodeOne.run(moveAction)
nodeTwo.run(moveAction)
nodeThree.run(moveAction)