Change Scenes between menu with a file structure of scenes

Hello,

I`m trying to make a game of cards, like a blackjack. But before the game, there is a menu, an start menu, with a logo and some buttons, to choose witch card game you want to play. After i click in the blackjack button, i should open the game in a different scene.

The point is, i`m trying to make a structure like this, i have te index.html, witch loads game.js, this game.js is the menu. When i click on blackjack, i would like the code to read blackjack.js, with a different scene.

What happens is that i`m unable to find any sample of this type os structure… all that i find is all scenes in the same file.

So, here is what is my file structure:

index.html - simple html loading a babylon file, index.js
index.js - HERE i would like to make primary scene to load the other scenes (game.js, blackjack.js, etc)
game.js - scene menu to choose a game - builded
blackjack.js - scene with the core game - not builded yet
card.js - class with suit and value - builded
deckofcards.js - class to build the deck and shuffle - builded

But happens that i didnt find any type of similar sample for this type os structure. Is there possible to build something like this in Babylon?

Thanks for the help.

Hey @Maya_Rahto, welcome to the Babylon family! So glad to have you here!

Check out these two docs. They’ll probably be a good resource as you explore this idea. In short, yes what you’re after is totally doable!

https://doc.babylonjs.com/features/scene

https://doc.babylonjs.com/how_to/multi_scenes

Hey @PirateJC, thanks for the answer.

Let me explain my doubt. with this sample here: https://www.babylonjs-playground.com/#MXCRPS#1 i would like to have separated files for each scene.

Per example:

On file 1, i wish to have, scene 0, as the sample.
On file 2, scene 1.
And, on file 0, the controller menu, to switch between file 1 and 2…

the problem is that i`m very newbie and i dont know how to implement that. If there is any sample with that…

I saw that a scene starts with window.addEventListener(‘DOMContentLoaded’, () => {…

Then, could i only import the other files? And in other files start with this same line, window.addEventListener… i think it is not like this.

And i didnt find any sample of multiple files of scenes.

Thats the point, i`m looking for a sample of multiple files, each file has a unique scene… so i could build many scenes as levels and importing classes like, card, deck, and make the rules for them in a separeted scene.

Does happens that u could help me with that?

I believe I understand what you’re trying to do, and while I haven’t done it myself, it seems like you’re not the only person to embark down this path. Here’s another thread on the subject that might be worth reading through as you experiment.

Thanks…but i`m newbie, didnt undertand to much without codes.

but i have solved in a crappy way… in the menu, there are buttons, then i use windows.location, to open the game in a new babylon app.