How to move an object in a path endlessly?

Hi All, I feel pretty dumb for not being able to figure this out but I wanted to see if anyone else had solved this issue before. I’m using the code found in this tutorial in the Corona Labs blog: https://coronalabs.com/blog/2014/01/07/tutorial-moving-objects-along-a-path/

and after messing around for almost two hours somehow I can’t figure out how one would make it follow the path in an endless loop. If anyone has done this before or can point me in the right direction I would be very grateful. Thanks in advance.

-Matt

Hi Matt,

In specific, what do you want to happen when the object reaches the end of the path? Should it revert back to the path start? Or are you creating a “joined” path (I guess that would be the same overall thing)?

Best regards,

Brent

Thanks for the reply Brent, I was trying to get it to just revert to the path start so it just continues in a smooth cycle. 

Hi Matt,

OK, this would basically involve adjusting some of the code in the “setPath()” function in that sample project. As it loops through and creates a transition for each path segment, you’d want to check if it’s the final iteration of that loop. If so, then for that specific transition (the final one), you’d want to add an “onComplete” parameter pointing to a function which would basically reset the object to the start and then call the “setPath()” function again to start the process over.

Take care,

Brent

Thanks so much for the help Brent I really appreciate you taking the time to help beginners like me, I’ll go try your solution now.

Hi Matt,

In specific, what do you want to happen when the object reaches the end of the path? Should it revert back to the path start? Or are you creating a “joined” path (I guess that would be the same overall thing)?

Best regards,

Brent

Thanks for the reply Brent, I was trying to get it to just revert to the path start so it just continues in a smooth cycle. 

Hi Matt,

OK, this would basically involve adjusting some of the code in the “setPath()” function in that sample project. As it loops through and creates a transition for each path segment, you’d want to check if it’s the final iteration of that loop. If so, then for that specific transition (the final one), you’d want to add an “onComplete” parameter pointing to a function which would basically reset the object to the start and then call the “setPath()” function again to start the process over.

Take care,

Brent

Thanks so much for the help Brent I really appreciate you taking the time to help beginners like me, I’ll go try your solution now.