Set Texture Source

Demonstrates how to change the underlying source data of a Texture at runtime, which automatically updates any Game Objects currently using that texture.

Set Texture Source, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.image('piggy', 'assets/pics/pigchampagne.png');
        this.load.image('atari', 'assets/sprites/atari130xe.png');
    }

    create ()
    {
        const piggy = this.add.image(400, 300, 'piggy');

        const textureA = this.textures.get('piggy');
        const textureB = this.textures.get('atari');

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

            textureA.setSource(textureB.source);

        });
    }
}

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

const game = new Phaser.Game(config);

More in Textures36 examples