Scene selection (Solved)

Hello, I wonder if there is a tutorial teaching how to use the Gdevelop storage to create a stage selection system.

I am newbie in GDevelop

Sorry, what do you mean with “phase selection system”? :slight_smile:

can only choose the gray stage, and if I pass the first stage I can choose to play the second

forgiveness for the english, I am using the Google translator…

OK, do you mean level selection, in-game scene selection system :slight_smile:

I’ll explain it with buttons (you can modify it to work with your own system, the same concepts) :wink:
Basically, you have to “link” the button with the scene/level, and you need to track the available scenes/levels in global variables, finally “link” the global variables with the buttons:

As you know, the action to change the current scene takes a string as parameter. To make a link between the button and scenes you can add an object variable in the button, for example “SceneName”, and set the value as the scene name associated to the button. Then, you can do it:

Conditions: Mouse right button is pressed Cursor is over Button Actions: Go to scene Button.VariableString(SceneName)
Now you have working buttons, but all of them work, how to decide if a button should work or not?

Let’s assume your level system is lineal (you have level 1, then level 2, 3, 4, etc.) and you can enter in a level if you have finished the previous one:
You just need a global variable, for example “HighestLevel”, this global variable will track the highest level you have finished. In every scene you should increase this variable if the level is greater than the variable, something like:

Conditions: Level finished (your condition to win a level) Variable LevelNumber is > than GlobalVariable(HighestLevel) Actions: Do = Variable(ThisLevelNumber) to the global variable HighestLevel
Every scene should have a scene variable with the value of the level (1,2,3, etc.). Note that the scene level number should be > (or >=) than the highest level to modify it, other way, if you have finished the level 5 and you play the level 2 again, the highest level will be 2… to bad :neutral_face:

Finally you have to link the buttons and the global variable HighestLevel. Now every button needs a variable with the value of the level, for example the button to go to the first level should have a variable LevelNumber = 1. The event to press the button needs to be updated:

Conditions: Mouse right button is pressed Cursor is over Button Button.Variable(LevelNumber) <= GlobalVariable(HighestLevel) +1 Actions: Go to scene Button.VariableString(SceneName)
Note the “+1” when checking the highest level, if you finish the level 3, you can advance to level 4, 4 is <= 3+1 :slight_smile:

If you have any question, your level system is not linear/ something more custom, or you need an example, just let us know to discuss here :smiley:

1 Like

Thanks man =D

One more question: how to save the game progress with webstorage ?

Button.Variable(LevelNumber) <= Button.Variable(HighestLevel) +1

is it right ? HighestLevel isn’t a global variable ? :confused:

You have to use the standard conditions/actions related to storage (Conditions/Actions >> Storage). This level selection system only needs to save the global variable HighestLevel.

Good catch!, I’ve edited it, thanks :slight_smile:

Thank you very much for helping me =D

I want to make a game of 5 level. I have 7 scene …Menu scene,Levelup scene,Game Over,Level 1,2,3,4,5 . Total 7 scene. So when I will launch the game The menu scene apear. After I press start it will go to level 1 after completing level 1 the scene change to Level up scene .In the level up scene there is a button named Next level. When I press next level it will change the scene to Level 2.After completing level 2 the scene change to Level up scene.When I press next level again it will change the scene to Level 3. Please help me. I am stuck .I tryed pop up layer also but it didnt work

Can you please do it for me? I am having problem of making this Level scene

https://we.tl/t-i55S9knFwz

Did you found how to make it?