Load HTML to Texture

Demonstrates how to load an external HTML file and convert it into a texture that can be used by Game Objects like Images or Sprites.

Load HTML to Texture, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    image;

    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.htmlTexture('test1', 'assets/html/test1.html', 512, 512);
    }

    create ()
    {
        this.image = this.add.image(400, 300, 'test1').setOrigin(0);
    }

    update ()
    {
        this.image.rotation += 0.01;
    }
}

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

const game = new Phaser.Game(config);

More in Loader12 examples