Load Image From Object

Demonstrates how to load an image by passing a single configuration object containing the key and URL to the loader instead of using separate arguments.

Load Image From Object, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.image({
            key: 'taikodrummaster',
            url: 'assets/pics/taikodrummaster.jpg'
        });
    }

    create ()
    {
        this.add.image(400, 300, 'taikodrummaster');
    }
}

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

const game = new Phaser.Game(config);

More in Image7 examples