When I try to refactor my code into a multi scene, it breaks. It only loads background image and one text, and then that’s it.
I put my config at the very bottom, don’t know what else to do.
const gameState = {
}
class FirstScene extends Phaser.Scene {
constructor(){
super({ key: 'FirstScene' })
}
preload() {
this.load.image('bg', './images/sky.png');
this.load.image('mummy', '/images/mummy.png');
this.load.image('daddy', './images/daddy.png');
this.load.image('sarai', './images/Sarai.png');
this.load.image('israel', './images/Israel_orange_crop.png');
this.load.image('sahara', './images/Sahara.png');
this.load.image('arrow-left', './images/arrow-left.png');
this.load.image('arrow-right', './images/arrow-right.png');
this.load.image('ground', 'images/platform.png');
}
create() {
gameState.background = this.add.image(0, 0, 'bg').setOrigin(0, 0);
startText = this.add.text(260, 100, 'Choose character', { fontSize: '30px', fill: '#000000' });
charactersArray = ['mummy', 'daddy', 'sarai', 'israel', 'sahara'];
gameState.character = this.add.sprite(380, 400, 'mummy').setScale(.35).setInteractive();
gameState.character.on('pointerup', () => {
startText.destroy();
arrowLeft.destroy();
arrowRight.destroy();
});
// more code there
}
so , everything after the second line in create() won’t display, i tried changing things around, removing some, nothing works. But same code in a single scene game works fine. (Instead of scene: [FirstScene]
, there’s just scene: {preload, create, update}