Merge Rectangle with XY Point
Demonstrates how to expand a rectangle's dimensions to encompass a new set of X and Y coordinates using the MergeXY method.
800 × 600
class Example extends Phaser.Scene
{
create ()
{
const graphics = this.add.graphics({ lineStyle: { width: 2, color: 0x0000aa } });
const rect = new Phaser.Geom.Rectangle(350, 250, 100, 100);
this.input.on('pointerdown', pointer =>
{
Phaser.Geom.Rectangle.MergeXY(rect, pointer.x, pointer.y);
redraw();
});
redraw();
function redraw ()
{
graphics.clear();
graphics.strokeRectShape(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);