2

There are two actions to run, one is move the object from pointA to pointB, the other is move the object from pointB to pointC. But when I execute them soon enough, the object will move from pointA to pointC directly.

beed.sprite1.position = A

let moveA = SKAction.moveTo(B, duration: 0.2)
beed.sprite1.runAction(moveA)

let moveB = SKAction.moveTo(C, duration: 0.2)
beed.sprite1.runAction(moveB)

It seems a interesting feature in sprite kit. What should I do so I can execute them step by step, that is, move the object from pointA to pointB, THEN, move it from pointB to pointC?

Thanks,

1
  • Did you ever find a solution for this? It's driving me mad, as for me also, combining the actions into one sequence is not an option. I also have to execute them step by step - even under user single-step control.
    – Marakai
    Apr 21, 2017 at 11:32

1 Answer 1

2

Adding the actions to an SKAction Sequence would probably be your best bet.

beed.sprite1.position = A
let moveSequence = SKAction.sequence([
SKAction.moveTo(B, duration: 0.2),
SKAction.moveTo(C, duration: 0.2)])
beed.sprite1.runAction(moveSequence)
4
  • 1
    One more related question, what if I have action sequences which is created at different time and I want to execute them sequentially?
    – allenlinli
    Jul 16, 2014 at 5:48
  • @AllenLin Your question makes no sense at all. Jul 16, 2014 at 5:49
  • @AllenLin Yes, but it just sounds like the question in the OP. Jul 16, 2014 at 23:21
  • This is very belated but his question makes perfect sense - and I'm facing the same situation: the actions may be discrete in that other things happen in between, even user input. Combining the actions into one sequence is not an option.
    – Marakai
    Apr 21, 2017 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.