Phaser.Curves.Path question

I’m trying to create a closed elliptical path using Phaser.Curves.Path but can’t seem to figure it out? Anyone have any sample code? I’ve been trying to hack this with little luck.

Also, I’m wondering if it’s any more efficient to move an object along a path using a tween or to move it manually in an update method? For example, would it be a little performance heavy if I used a simple sine function to move an object around a screen by brute force re-positioning on each frame?

edit: Looks like creatingcustom tweens is not too hard at all…

This example looks like a closed elliptical path. It is done with a timeline with multiple tweens.

I guess you could also use a simple sine function as an alternative. Some interesting readings about this topis:

Thanks @digitsensitive, that looks like a fit. My preferred approach would definitely to be use math functions to manually move objects around the screen. I guess I just want to be sure it’s not going to be too performance heavy as I plan to have quite a few bodies orbiting around the screen at any one time.

I would like to use some strange attractors to control their positions. I guess I’ll just try it out and see. The other options would be to define my own tween Ease, but I don’t know enough about how they work to do that. I’m sure I’ll find an example somewhere though…

Hi @rorywalsh,
This code uses the class Phaser.GameObjects.PathFollower and a closed elliptical path:

See the Pen [Phaser 3] Basic follower object example by Juan Jose Capellan (@jjcapellan) on CodePen.

Regards.

Code fixed.

Great. Thanks @jjcapellan!

https://labs.phaser.io/view.html?src=src/paths\curves\ellipse%20curve.js

Great. I’ve implemented it myself in the update function as:

update (time, delta)
{        
        this.planet.x = 400+ Math.sin(2*3.14*(time/1000)*this.freq)*200;
        this.planet.y = 200+ Math.cos(2*3.14*(time/1000)*this.freq)*100;
}

Would using tweens be more efficient? Note that I will use a wavetable table for the sine shape so I don’t have to keep calling sin(). That should also speed things up a bit.