Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move sprite along path

I'm working with SpriteKit and wondering if anyone knows how to make a sprite follow a path. I've seen other questions online that talk about moving a sprite along a CGPath, but how would you do it if the path is another sprite?

Video example

like image 252
Otto Gutierrez Avatar asked Aug 27 '26 09:08

Otto Gutierrez


1 Answers

Have a look at Is there a way to create a CGPath matching outline of a SKSpriteNode? - it seems from that answer that the problem is much more complex than it first appears.

If your sprite is an SVG, a simpler solution may be to manually convert the SVG into a CGPath, and then using that CGPath in your game. A simple tool for doing that is available here: https://swiftvg.mike-engel.com/. Of course doing this manually won't scale well if you have many different sprites.

This may not be exactly the answer you are looking for, but it seems right now there is no simple way to accomplish what you need :)

like image 178
JohnV Avatar answered Aug 30 '26 03:08

JohnV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!