Line Angle

Calculate and display the angle of a rotating Line geometry object using the Line.Angle method.

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

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

        this.line = new Phaser.Geom.Line(200, 300, 600, 300);

        this.text = this.add.text(100, 50, '');
    }

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

        this.graphics.clear();

        this.graphics.strokeLineShape(this.line);

        const angle = Phaser.Geom.Line.Angle(this.line);

        this.text.setText(`Line Angle: ${Phaser.Math.RadToDeg(angle)}`);
    }
}

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