Using plugin

Hello. I am building a game in Phaser 3 and now I wanted to add a Rex Plugin, this one Await Loader . I can’t figure out how to set it up. I didn’t want to install NPM and all those things. Is there a simple, cleaner way to add the plugin?

Thank you

Hi @amserra,

If you don’t want to use NPM, you will need to get a copy of the minified version of the plugin to use it in your game. I am not sure if the Rex plugins are available through a CDN, but it might be worth checking.

Once you have the minified version of the code, you just need to load that script after you load the Phaser library, and then you can reference the rexawaitloaderplugin in the plugin section of the game config.

Here is an example snippet:

var config = {
      type: Phaser.AUTO,
      parent: 'phaser-example',
      width: 800,
      ...
      plugins: {
        global: [{
          key: 'rexAwaitLoader',
          plugin: rexawaitloaderplugin,
          start: true
        }]
      }
    };

You can download the minified version of the plugin from GitHub here: Rex Await Loader Plugin

You can see an example of how to use the plugin on CodePen here: Example.

You can also find an example Gist here: Example

1 Like

@scottwestover you’re awsome. Thank you so much.
Hope the best for you.

@scottwestover has provided a good answer.

You also can instal plugin from external file.
Since AwaitLoader plugin is used in preload stage usually, it is better install it before starting a scene.
Here is another example of installing plugin before starting a scene. See line 15, and line 19.

1 Like