Otto Gutierrez
Otto Gutierrez

Reputation: 487

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

Upvotes: 3

Views: 462

Answers (1)

JohnV
JohnV

Reputation: 990

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 :)

Upvotes: 1

Related Questions