Loading a Scene Plugin

Demonstrates how to dynamically load a Scene Plugin and use its injected property to create and animate specialized content within a Scene.

Loading a Scene Plugin, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.scenePlugin({
            key: 'FractalPlugin',
            url: 'assets/loader-tests/FractalScenePlugin.js',
            sceneKey: 'fractals'
        });
    }

    create ()
    {
        const image = this.fractals.create(400, 300, 256, 256);

        image.setScale(2);

        this.tweens.add({

            targets: this.fractals,
            v1: 1.5,
            v2: -3.0,
            v3: 1.0,
            v4: -2.0,
            duration: 4000,
            yoyo: true,
            repeat: -1

        });

        this.tweens.add({

            targets: this.fractals,
            c1: 16,
            c2: 10,
            c3: 0,
            duration: 16000,
            yoyo: true,
            repeat: -1

        });
    }
}

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

let game = new Phaser.Game(config);

More in Plugins17 examples