Transparent Game Canvas

Configure a Phaser game to have a transparent canvas, allowing the underlying HTML page or CSS background to show through the scene.

Transparent Game Canvas, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.image('pic', 'assets/pics/forgotten-worlds.png');
    }

    create ()
    {
        //  This just injects an image into the div background, so you can see the transparency working.
        const div = document.getElementById('phaser-example');

        div.style.background = 'url(assets/demoscene/multi-color-raster.png)';

        this.add.image(400, 600, 'pic').setOrigin(0.5, 1);
    }
}

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

const game = new Phaser.Game(config);

More in Game Config19 examples