Vignette Radius

Demonstrates how to use and animate the radius property of the Vignette effect to dynamically change the size of the vignette on Game Objects.

Vignette Radius, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    constructor ()
    {
        super();
    }

    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.image('pic', 'assets/pics/anime-ai.jpg');
        this.load.image('test', 'assets/sprites/phaser3-logo.png');
    }

    create ()
    {
        const bg = this.add.image(400, 300, 'pic').enableFilters();
        const logo = this.add.image(400, 500, 'test').enableFilters();

        const fx = bg.filters.internal.addVignette(0.5, 0.5, 0, 0.5);
        const fx2 = logo.filters.internal.addVignette(0.5, 0.5, 0, 0.2, new Phaser.Display.Color(0, 0, 0, 0)); // Alpha vignette

        const text = this.add.text(10, 10, 'FX.Vignette.radius: 0');

        this.tweens.add({
            targets: [ fx, fx2 ],
            radius: 1,
            duration: 4000,
            yoyo: true,
            loop: -1,
            hold: 1000,
            onUpdate: () => {
                text.setText(`FX.Vignette.radius: ${fx.radius}`);
            }
        });

        this.tweens.add({
            targets: logo,
            y: 550,
            duration: 1000,
            yoyo: true,
            loop: -1,
            ease: 'sine.inout'
        });
    }
}

const config = {
    scale: { mode: Phaser.Scale.FIT },
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    backgroundColor: '#000000',
    parent: 'game-container',
    scene: Example
};

let game = new Phaser.Game(config);

More in Vignette6 examples