Skip to content

Instantly share code, notes, and snippets.

@scottwestover
Last active May 17, 2019 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottwestover/ee7f1636c27d9f95591cf633cf77ea71 to your computer and use it in GitHub Desktop.
Save scottwestover/ee7f1636c27d9f95591cf633cf77ea71 to your computer and use it in GitHub Desktop.
Phaser 3 Rex Plugin Example
<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/3.17.0/phaser.min.js"></script>
<script src="rexawaitloaderplugin.min.js"></script>
<script>
var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 800,
height: 600,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
scene: {
create,
preload
},
plugins: {
global: [{
key: 'rexAwaitLoader',
plugin: rexawaitloaderplugin,
start: true
}]
}
};
var game = new Phaser.Game(config);
function create() {
this.text = this.add.text(this.scale.width / 2, this.scale.height / 2, 'hello world', {
fontSize: 64
});
this.text.setOrigin(0.5);
}
function preload() {
console.log('preload');
var callback = function (successCallback, failureCallback) {
setTimeout(successCallback, 1000);
}
this.load.rexAwait('fn0', {
callback: callback
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment