My code is compartmentalized over many files, so I hope I can describe this easily.
I have a path that goes from point A to point B
I place an SKSpriteNode at point A and execute:
I execute that SKACtion and as I expected, my SKNode goes from point A to point B. Fine.
I'm not sure how to reverse it, I assumed from the dox that calling that same SKAction as is, would make the SKNode go from point B to A.
I have a path that goes from point A to point B
I place an SKSpriteNode at point A and execute:
Code Block iconPath[0] = the path SKAction.follow(iconPath[0], asOffset: false, orientToPath: false, duration: 1))
I execute that SKACtion and as I expected, my SKNode goes from point A to point B. Fine.
I'm not sure how to reverse it, I assumed from the dox that calling that same SKAction as is, would make the SKNode go from point B to A.
Actually someone gave me an easier answer on StackOverflow. This is a quote from the link below
There is a method called reversed() which you could use.
Below I have given your action a name of "youraction"
Alternatively, you can just use reversed after the action name to run it in reverse:
https://stackoverflow.com/questions/66354936/how-can-i-have-an-skspritenode-follow-the-same-path-back-and-forth/66357189#66357189
There is a method called reversed() which you could use.
Below I have given your action a name of "youraction"
Code Block let youraction = SKAction.follow(iconPath0, asOffset: false, orientToPath: false, duration: 1) let reverseaction = SKAction.reversed(youraction) yourspritenode.run(reverseaction)
Alternatively, you can just use reversed after the action name to run it in reverse:
Code Block yourspritenode.run(youraction.reversed())
https://stackoverflow.com/questions/66354936/how-can-i-have-an-skspritenode-follow-the-same-path-back-and-forth/66357189#66357189