-
-
Save scottwestover/ee7f1636c27d9f95591cf633cf77ea71 to your computer and use it in GitHub Desktop.
Phaser 3 Rex Plugin Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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