Flip Y

Demonstrates how to vertically flip an image using the setFlipY method, the flipY property, and the toggleFlipY function.

Flip Y, running
1024 × 768
GitHub
class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.image('pic', 'assets/pics/cougar-face-of-nature.png');
    }

    create ()
    {
        //  Default non-flipped image
        this.add.image(250, 164, 'pic');

        //  Flipped via a call to setFlipY
        this.add.image(250, 464, 'pic').setFlipY(true);

        const image = this.add.image(650, 164, 'pic');

        //  Flipped via setting the flipY property
        image.flipY = true;

        const image2 = this.add.image(650, 464, 'pic');

        this.input.on('pointerdown', () =>
        {

            //  Flipped via a call to toggleFlipX
            image2.toggleFlipY();

        });
    }
}

const config = {
    scale: { mode: Phaser.Scale.FIT },
    type: Phaser.AUTO,
    parent: 'game-container',
    scene: Example
};

const game = new Phaser.Game(config);

More in Transform13 examples