Creating and Drawing Points
Demonstrates how to initialize Vector2 objects using various constructor arguments and render them as filled shapes using a Graphics object.
800 × 600
class Example extends Phaser.Scene
{
create ()
{
const graphics = this.add.graphics({ fillStyle: { color: 0x2266aa } });
const point1 = new Phaser.Math.Vector2();// point at 0/0
const point2 = new Phaser.Math.Vector2(100);// point at 100/100
const point3 = new Phaser.Math.Vector2(400, 300);// point at 400/300
graphics.fillPointShape(point1, 15);
graphics.fillPointShape(point2, 15);
graphics.fillPointShape(point3, 15);
}
}
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);