Skip to content

Loading animation scene

Introduction

Start loading animation scene, stop this scene when loading complete.

  • Author: Rex
  • Methods

Live demos

Loading animation scene

Usage

Sample code

Install plugin

Load minify file

  • Load plugin (minify file) in preload stage
    scene.load.plugin('rexloadinganimationsceneplugin', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rexloadinganimationsceneplugin.min.js', true);
    
  • Start loading animation scene
    scene.plugins.get('rexloadinganimationsceneplugin').startScene(scene, animationSceneKey);
    
  • This plugin will also install AwaitLoader.

Import plugin

  • Install rex plugins from npm
    npm i phaser3-rex-plugins
    
  • Install plugin in configuration of game
    import LoadingAnimationScenePlugin from 'phaser3-rex-plugins/plugins/loadinganimationscene-plugin.js';
    var config = {
        // ...
        plugins: {
            global: [{
                key: 'rexLoadingAnimationScene',
                plugin: LoadingAnimationScenePlugin,
                start: true
            },
            // ...
            ]
        }
        // ...
    };
    var game = new Phaser.Game(config);
    
  • Start loading animation scene
    scene.plugins.get('rexLoadingAnimationScene').startScene(scene, animationSceneKey);
    
  • This plugin will also install AwaitLoader.

Import class

  • Install rex plugins from npm
    npm i phaser3-rex-plugins
    
  • Import class
    import StartLoadingAnimationScene from 'phaser3-rex-plugins/plugins/loadinganimationscene.js';
    
  • Start loading animation scene
    StartLoadingAnimationScene(scene, animationSceneKey);
    

Start loading animation scene

scene.plugins.get('rexLoadingAnimationScene').startScene(scene, animationSceneKey);
// scene.plugins.get('rexLoadingAnimationScene').startScene(scene, animationSceneKey, animationSceneData);
  • Will stop animationScene when preloading complete.

or

scene.plugins.get('rexLoadingAnimationScene').startScene(scene, animationSceneKey, onLoadingComplete);
// scene.plugins.get('rexLoadingAnimationScene').startScene(scene, animationSceneKey, animationSceneData, onLoadingComplete);
  • onLoadingComplete : Custom task
    function(finishLoading, animationScene) {
        // finishLoading();
    }
    
    • Invoke finishLoading() method (later) to finish current loading progress.