Point Ceil

Demonstrates rounding a point's coordinates up to the nearest integer using the ceil method.

Point Ceil, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    y = 100;
    graphics;
    text2;
    text1;
    point2;
    point1;

    create ()
    {
        this.graphics = this.add.graphics({ fillStyle: { color: 0x2266aa } });

        this.point1 = new Phaser.Math.Vector2(300, 100);
        this.point2 = new Phaser.Math.Vector2(500, 100);

        this.text1 = this.add.text(100, 50, '');
        this.text2 = this.add.text(500, 50, '');
    }

    update ()
    {
        this.y += 0.05;

        this.point1.y = this.point2.y = this.y;
        this.point2.ceil();

        this.text1.setText(`y: ${this.point1.y}`);
        this.text2.setText(`y: ${this.point2.y}`);

        this.graphics.clear();
        this.graphics.fillPointShape(this.point1, 20);
        this.graphics.fillPointShape(this.point2, 20);
    }
}

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);

More in Point18 examples