Stroke Rect
Demonstrates how to draw the outline of a rectangle using the Graphics object, including setting the line thickness, color, and alpha.
800 × 600
class Example extends Phaser.Scene
{
graphics;
create ()
{
this.graphics = this.add.graphics();
const color = 0xffff00;
const thickness = 2;
const alpha = 1;
this.graphics.lineStyle(thickness, color, alpha);
this.graphics.strokeRect(32, 32, 256, 256);
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
width: 800,
height: 600,
type: Phaser.CANVAS,
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);