Phaser.GameObjects.GameObjectFactory API wrong?

Hi, first post :slight_smile:

I’m very confused about how to properly use scene.add.line() as the examples here https://labs.phaser.io/edit.html?src=src/game%20objects/shapes/line.js&v=3.19.0 don’t seem to match up in any way with the docs here https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.GameObjectFactory.html#line__anchor note that according to the docs, there are three pairs of x,y in the signature, the second and third pair allegedly form the start and end of the line, but then the first pair is the position…? That doesn’t seem to make any sense, how can you be specifying the start, end, and position at the same time?

In the example it looks like they’re omitting (by setting to zero? how is that differentiated from actually specifying zero?) the second pair in the signature, eg:

this.add.line(200, 200, 0, 0, 140, 0, 0x6666ff);

But the effect of this code seems to be “center the line at 200,200 and make it stretch 140px to the right, which is to say, from 70px to the left of center to 70px to the right of center” are we supposed to do something like specify where it starts from, where it ends, and then manually place it by where the center is? Why is none of this in the docs?

Basically what I’m trying to do is have a line connect two circles (well, scene.add.circle is apparently technically an arc, so two arcs) and then tween the circles around and also tween the ends of the line around. This seems easy enough to do with Phaser.Geom.Line as it has x1,y1,x2,y2 as member variables but Phaser.GameObject.Line has member variables that make very little sense, certainly no x1 and x2. Should I just give up on Phaser.GameObject.Line and draw them manually with graphics and Phaser.Geom.Line or is there some sort of witchcraft I’m missing for tweening a game object line between two points?

After hacking around at trying to figure out some way to make Phaser.GameObject.Shapes.Line be dynamic and not just shiftable I think I’m giving up. Looks like Shapes.Line is a sort of 2 vertex polygon? None of the member variables seem to do a thing to its shape so I’m guessing it’s one of the path-related variables that stores that data, which means redefining paths over and over I guess which is way too many backflips to nudge a line so I’ll just do the Phaser.Geom.Line approach which is very trivial to tween (just tween x1,y1,x2,y2) kind of a shame that I can’t use game objects for this but I guess ultimately this is probably just as good.

Just thought I’d follow up in case anyone else is pulling their hair out over Shapes.Line. Happy hunting!

You can tween line.geom.{left, top, right, bottom}.

Hmm okay, so it sounds like in that case I’d have to manually calculate everything myself about how big the line needs to be and where to rotate it to, which I guess is fine performance-wise since it’s just at the beginning of the tween. Should I run into performance pains with using graphics then I’ll give this a shot, thanks.