[Solved] Make a "you won" scene after each level that lets the player click a button for the next level, or a button to a scene of all unlocked levels/

I ended up making the “all levels” section it’s own scene. I just realized that the darkened area of your screen grab has the actions as child actions of things from the “you won” screen.

How can I make it work on it’s own scene?

I tried putting the following at the end of each playing level, but it isn’t changing the level selection scene.

I’m assuming you’ll have a “you win” scene, which opens up a level selection scene?

If so, put the event setting the global variable max_level_unlocked in the “you win” scene, and take it out of all the level scenes.

Then, using my screen snip a few posts back, put the events from the second comment onwards into the level selection scene, along with buttons for all the levels.


Don’t set max_level_unlocked here. Do that in the “you win” scene.

OK. I did what you just wrote to do.

Now when I finish the first level, it unlocks the first 3 levels. (I just want it to unlock 1 and 2 at that point), but when I finish level 2, only 1 and 2 are unlocked, when I would think 1, 2, and 3 should be unlocked at that point.

I put the max(GlobalVariable(max_level_unlocked),GlobalVariable(current_playing_level) +1) in the “at the begining” section of the “you win” scene. Is that a good place for it?

This repeat should be a subevent of a “At the beginning of the scene” event, and get called once at the start of the scene :


The last event should be called every frame, and should not be a subevent of that beginning of scene event:

That was already like that, but I went ahead and changed the repeat to be a subevent of a “at the beginning” like you mentioned. But it’s still doing the same thing. No levels are unlocked until after the first level is cleared (so you can’t even play the first level by clicking on the “Level Selection” screen, and after you complete the first level, it unlocks levels 1-3. Even though you haven’t finished the second level yet.

Set max_level_unlocked to 1 in the editor, in the global variables definition (in my screen screen snip back a way it’s set to 0, change t to 1). This’ll unlock the first level.

This points to 2 places where it’s increasing max_level_unlocked. Can you provide screen snips of the level selection scene events, level1 scene events and the “you won” scene events? It smells like it’s double dipping somewhere.

That fixed that issue. Thanks!

I looked really closely at all the actions and the variables that related to all of this and realized that I hadn’t updated the one related to what each level was numbered. I had decided that the level I made as level 1 had gotten harder to play and would work better as a level 2, but I hadn’t updated the variables so level 1 was listed as #2 and Level 2 was listed as 1.

Now everything works! Thanks again for all the help, @MrMen

1 Like

@MrMen I spent hours pouring over videos and tutorials trying to understand how to store the levels the player has unlocked, and I am very confused.

Should I write a value to storage of the max_levels_unlocked (global variable), and save that to storage? If so, do I do that at the very end of the “you win” scene and then read it on the “level selection” scene? I feel like I’m close to understanding this, but I’m not sure.

Write it to storage in the same event you write all_level_times. It’s not the perfect place, but then you have your write events together.


Yes, you can read it there. Make it one of the first events in the scene.

The other option is to read it at the very start of your game, in the very first scene that opens the game. It only ever needs to be read n once. After that, it’ll get updated and be correct throughout the whole game.

Thanks. How do I check to make sure it worked?

Do I need to export it to a web page, then go to that page, play a few levels, close the page, reload the page and check?

It’d be quicker to just run it for a few levels in preview mode, straight from the editor.

But when I run it in preview mode, the levels unlocked worked with out writing or reading anything to storage. I want to check and make sure it will remember the unlocked levels even after the game is closed.
Are you saying that each time I run a new preview it should remember the saved levels info? If so, then I did something wrong because that is not what is happening when I open a new preview.

Make sure when you run from the editor, you have the start scene open and in focus in the editor. If you have a level scene open or in focus, that will get run instead.

I always start from the opening title scene.

Yes. In which scene do you read the storage value for max_level_unlocked?

The title scene. The one that shows instructions on how to play the game before people enter any gameplay.

You can check it’s in the storage from the GDevelop editor by using the ctrl + shift + i method.

If it’s not, check that you’re writing it correctly.

If it is in storage (with a value > 1), run it in debugger, and see if max_level_unlocked has a value other than 1.

Not sure I understood all of what you just wrote, but here’s a screen grab of the title scene and it looks like it is saving it.

levels_unlocked is what I added for saving it. And it looks like it unlocked to level 3.

But, as can be seen below, it is only unlocking level one.

What are the events for the level selection scene?