Phaser 3.60.0 don't work,error "ReferenceError: Phaser is not defined at IsSceneObject.js:1:20"
cydd007 opened this issue · comments
import RexUIPlugin from 'phaser3-rex-plugins/templates/ui/ui-plugin.js';
class GameScene extends Phaser.Scene {
constructor(config:any) {
super(config);
}
preload(){}
create(){}
}
var config:Phaser.Types.Core.GameConfig = {
type: Phaser.AUTO,
width: width,
height: height,
plugins: {
scene: [
{ key: 'rexUI', plugin: RexUIPlugin, mapping: 'rexUI'}
]
},
physics: {
default: 'arcade',
arcade: {
gravity: {y: 200 },
debug: false
}
},
scale: {
width: width,
height: height,
mode: Scale.CENTER_BOTH ,
},
scene: GameScene,
};
let phaserGame = new Phaser.Game(config);
When I am running in the browser,console error:
"ReferenceError: Phaser is not defined at IsSceneObject.js:1:20"
when i use this config:
var config:Phaser.Types.Core.GameConfig = {
type: Phaser.AUTO,
width: width,
height: height,
physics: {
default: 'arcade',
arcade: {
gravity: {y: 200 },
debug: false
}
},
scale: {
width: width,
height: height,
mode: Scale.CENTER_BOTH ,
},
scene: GameScene,
};
My program is running normally,Why?
Import phaser before rexUI package. Once phaser is imported, it will run window.Phaser = Phaser
, therefore rexUI can get reference of phaser module.
Please check that window.Phaser
is valid. Bundle toolchain might not export that instruction.
import RexUIPlugin from 'phaser3-rex-plugins/templates/ui/ui-plugin.js';
import Phaser from 'phaser';
The import order is wrong,modify:
import Phaser from 'phaser';
import RexUIPlugin from 'phaser3-rex-plugins/templates/ui/ui-plugin.js';
It's running