How do I create a line using this.add.line()?

I know we can use Phaser.Geom.Line() class and But how I can do it using only this.add.line() ? I have tried it, but there’s no visible line.

const line = this.add.line(0, 0 100, 100, 200, 200); // not showing

Hi @andraantariksa,
This function has 2 more parameters: strokeColor and strokeAlpha.

// shows a red line

Here the docs:


Thanks! I have notice the docs but I didn’t expect that leaving the strokeColor empty will gives me black color (I have a black background, so I didn’t notice it), I think they should mention it in the docs.

how can i do the same outside the create function. When i do it, i get a error like this : script.js:173 Uncaught TypeError: Cannot read properties of undefined (reading ‘line’)