Switch Scene not loading the game objects after clicked on second scene

I have 3 scenes : LOADBETCHO

app.js

import {Chohan} from './Game'
import { LoadScene } from "./scenes/LoadScene";
import { BetScene } from "./scenes/BetScene";
import {ChoScene} from "./scenes/ChoScene";

//Let go
const DEFAULT_WIDTH = 800
const DEFAULT_HEIGHT = 800

const config = {
title: "Chohan",
width: 800,
height: 800,
parent: "phaser",
dom: {
  createContainer: true
},
backgroundColor: "#dddddd",
scale: {
    parent: 'phaser',
    mode: Phaser.Scale.FIT,
    autoCenter: Phaser.Scale.CENTER_BOTH,
    width: DEFAULT_WIDTH,
    height: DEFAULT_HEIGHT
  },
   scene: [LoadScene, BetScene, ChoScene],
};

const game = new Chohan(config);

loadScene.js

 export default class loadScene extends Phaser.Scene {
  constructor() {
  super('LOAD');
}

preload() {
  this.load.image('phaser-logo', '/sprites/phaser-logo.png')
}

create() {
  this.scene.start('BET')

}
}

betScene.js

export class BetScene extends Phaser.Scene{
constructor() {
  super('BET');
}
init(data){
  console.log(data)
  console.log("I GOT IT")
}
create(){
 let left = this.add.image(430, this.game.renderer.height-90, "left").setDepth(1);
  let up = this.add.image(380, this.game.renderer.height-140, "up").setDepth(1);

  left.setInteractive().on(Phaser.Input.Events.GAMEOBJECT_POINTER_DOWN,()=>{
    console.log('From Scene MAIN')
    this.scene.start('CHO', "Hello From Menu Scene");
  });
  }
}

ChoScene.js

export default class ChoScene extends Phaser.Scene {
constructor() {
  super('CHO');
 }
 init(data){
  console.log(data)
  console.log("I am in Cho Scene")
}
   preload(){
   this.load.image("dealer","/sprites/dealer.png")
 }
 create() {
   console.log("I am here")
   this.add.text(0, 0, "Playing game", {font: "30px Arial", fill: "yellow"});
    }
}

it works from LOAD to BET scene , but when I am on the BET Scene , click on left button , I got the CHO scene loaded, but I did not see any objects there, a text , or even a console log which is in create function.

Anyone please help, what do I missed for this coding flow?
I am using Phaser: v3.24.1 .

Thanks in advance.

Sorry to answer my own question, by the way I just need to update to the community what I have try.

Now, I have solved problem my just change export default class ChoScene to export class ChoScene this fixed my issues.

1 Like