Create Rectangle Geometry
Demonstrates how to define a basic rectangle geometry object and render it filled with color using a Graphics object.
800 × 600
class Example extends Phaser.Scene
{
create ()
{
const rect = new Phaser.Geom.Rectangle(250, 200, 300, 200);
const graphics = this.add.graphics({ fillStyle: { color: 0x0000ff } });
graphics.fillRectShape(rect);
}
}
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);