0
votes

I am making an IOS game in Swift with Spritekit, I have a player Sprite which I want to rotate and move towards where a touch is on the screen. Currently I get the angle, Create the action to turn, Run the action and do the same for the movement. This works well for a single touch, However I now want to do the same when a touch moves. First I tried removing the action then running the new one, The sprite jitters or does not move at all, because the action is being cancelled very soon after being created. I have also tried running it every 100ms however I still do not get smooth movement.

So I was wondering is there any way to modify an action as it is running? Or what is the right way of doing this?

1
can you show your current code, how you are doing it. - Pratik

1 Answers

0
votes

You can override the didEvaluateActions method in your scene class, this gets called after all actions are performed in an update frame. In that method, destroy the old action and start your new action. If you are still seeing jitters, then you need to reevaluate when you want to be removing actions