Get Line Endpoints

Demonstrates how to use getPointA and getPointB to retrieve the start and end coordinates of a rotating Line geometry object.

Get Line Endpoints, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    graphics;
    line;

    create ()
    {
        this.graphics = this.add.graphics({ lineStyle: { width: 2, color: 0xaa00aa } });

        this.line = new Phaser.Geom.Line(250, 300, 550, 300);
    }

    update ()
    {
        Phaser.Geom.Line.Rotate(this.line, 0.02);

        this.graphics.clear();

        this.graphics.strokeLineShape(this.line);

        this.graphics.fillStyle(0xaa0000);
        this.graphics.fillPointShape(this.line.getPointA(), 10);

        this.graphics.fillStyle(0x0000aa);
        this.graphics.fillPointShape(this.line.getPointB(), 10);
    }
}

const config = {
    scale: { mode: Phaser.Scale.FIT },
    width: 800,
    height: 600,
    type: Phaser.AUTO,
    parent: 'game-container',
    scene: Example
};

const game = new Phaser.Game(config);

More in Line31 examples