Using graphics object results in error

Hello there,

when I try to use the graphics object, I get an error.

I tried the code from the API Documentation (https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Graphics.html)

graphics.lineStyle(5, 0xFF00FF, 1.0);
graphics.beginPath();
graphics.moveTo(100, 100);
graphics.lineTo(200, 200);
graphics.closePath();
graphics.strokePath();

And then I tried the code from several examples. I always got that error.
Can anyone tell me how to draw, e.g. a line without getting that error?

I think it was caused by me having another draw thing.
I deleted it and the error is gone.
Is something wrong with that renderTexture thing?

var rt;
rt = this.add.renderTexture(0, 0, 800, 600);
rt.draw();

rt.draw expects an object. It can’t draw nothing…

draw(entries [, x] [, y] [, alpha] [, tint])

Draws the given object, or an array of objects, to this Render Texture.

2 Likes

Thanks. That explains it.