Issues with Scene loading and switching

Hi I’m new to this so please bear with me, I’m a webdev student and I had to create a game for HTML5 within 4 days, coming from godot I thought Phaser JS would eb a nice framework. I opted to create a turn based rph and was following this tutorial and honestly it’s been challenging cause the code is kinda messy and weird and a lot deprecated references to phaser 2
Anyway, I have been trying to reestructure the whole thing to switch scenes when combat is supposed to trigger
I have the index.html

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src=""></script>
    <script src="./src/game.js"></script>
    <script src="./src/world.js"></script>
    <script src="./src/start.js"></script>

I noticed that depending on how I order the scripts, they screens appear next to each other(which is not what I want) but somehow no matter how i move them around the battle scene will always display but the other won’t sometimes ,
Additionally if the game.js doesn’T go firsr I get an error start.js:15 Uncaught ReferenceError: WorldScene is not defined OR Bootscene is not defined. (screenshots below)

for refrence this is the start file

var config = {
  type: Phaser.AUTO,
  parent: "content",
  width: 320,
  height: 240,
  zoom: 2,
  pixelArt: true,
  physics: {
    default: "arcade",
    arcade: {
      gravity: { y: 0 },
      debug: false, // set to true to view zones
  scene: [BootScene, WorldScene, BattleScene, UIScene],
var game = new Phaser.Game(config);

I read on some posts here that the loading order matters but I’ve tried every iteration
Also for ref, in the world.js file first the Boorscene class is defined and then the Worldscene class
the game.js is the battle scene and it’S far more complex

I would greatly appreaciate some help because I have to have this project quasi finalized by tomorrow and if I manage to switch scenes I can then work on assets and polish

It should work if all the scene scripts come first and start.js is last. The scenes should be global variables and there should be only one new Phaser.Game(config) anywhere.

If you’re really stuck, you can just put all the code in one long script, with new Phaser.Game(config) at the bottom.

1 Like

Thanks for your response! By the time iit got published I had already figured I had two configs that were conflicting.
Dumb mistake.
Now I
m having an issue resetting the combat scene after i bear the enemy because if i trigger another encounter the scene is as it ended (enemy dead) :confused: but I’ll probably open a separate thread for that