Vector2 Set To
Demonstrates using the setTo method to update the coordinates of a Vector2 object with various argument combinations.
800 × 600
class Example extends Phaser.Scene
{
create ()
{
const graphics = this.add.graphics({ fillStyle: { color: 0x2266aa } });
const point = new Phaser.Math.Vector2(400, 300);
graphics.fillPointShape(point, 10);
point.setTo();
graphics.fillPointShape(point, 15);
point.setTo(100);
graphics.fillPointShape(point, 20);
point.setTo(200, 100);
graphics.fillPointShape(point, 25);
}
}
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);