I have code using 2d context:
const points = [{ x: 200, y: 200 }, { x: 500, y: 500 }];
const gradient = c.createLinearGradient(0, 0, canvas.width, canvas.height);
gradient.addColorStop(0, ‘rgba(200, 200, 200, 1)’);
gradient.addColorStop(1, ‘rgba(200, 200, 200, 0)’);
c.lineWidth = 10;
c.lineJoin = ‘round’;
c.lineCap = ‘round’;
c.strokeStyle = gradient;
c.beginPath();
c.moveTo(points[0].x, points[0].y);
c.lineTo(points[1].x, points[1].y);
c.stroke();
How can I achieve the same effect using Phaser?
You can use a Canvas Texture and Image game object. See the labs examples in Textures.