Convert a scene to an external layout

When a player finishes each level, a “congrats! You did it!” scene is currently run.

I want to make that “congrats” scene an external layout so I can have it play within the current scene so I can have buttons for “replay” and “next level”.

Can I convert the current “congrats” scene to an external layout? Or is there a better way to do this? I already have all the logic in the “congrats” scene, so from what I have read about external layouts, I am assuming I will need to move that logic to the main scene. But other than that I was hoping not to have to start over on the “congrats” scene for the external layout.

If there is a completely different way that makes more sense to accomplish the “replay” and “next level” buttons that don’t require external layouts, feel free to suggest another method.


If you use the congrats screen for each level, and each level is a scene, then I’d look at using the external events for the code/events behind the external layout.

I don’t know of an easier way than to just cut and paste, for both external events and layout. With the layout, first set all the congrats scene objects as global objects. Then you can cut them, open the external layout and paste them.

For the external events, copy and paste all the events from the current scene events to the new external events script.

1 Like

Easy way I see here is for you to create an external Layout and move the congrats events to an external event sheet then link the congrats events to your game scene at the begin of the scene set the Congrats layout to be invisible then when the player wins a level just set congrats layout to be visible and maybe with a boolean true/false run the events into the congrats eventsheet

1 Like

Since the main character is a physics object that will be moving when it triggers the end of the scene, and the camera is following that object. Do a trigger switching the main character sprite from dynamic to static, and will I need to have an action that moves the elements to the external event to where ever the main character is at that moment? The trigger that signifies the end of the level is in different places on each level.

Or should I just always have the external layout in the same place on each level, but use some action to move the camera to the center of it?

I’m trying to wrap my head around (hopefully all of) the things that will need to be changed to bring the “congrats” scene elements into each level.

Create a new layer, say called MessageLayer, and put all the congrats external layer objects on that. It’ll act the same way as, say, having a UI layer. Don’t move the camera for the congrats layer, and you won’t need to worry about repositioning the objects.

Oh! I am disappointed in myself for not thinking of that. I am already using a UI Layer that works that way. I didn’t even think to connect it to this issue. Thanks! That is so much easier.

I am using an action as the scene begins to “hide CongratsLayer” and upon the main character hitting the finish line sprite, “show CongratsLayer” (last part as seen in the following screen shot).

But it isn’t showing the CongratsLayer. Any thoughts on what to look for that I may have done wrong? I triple checked, and all items I want displayed are on the CongratsLayer.

If you remove the hide layer action, do the objects on the CongratsLayer appear on screen of the level? Not in the external layout in the editor, but on screen once the game level actually starts?

Smart thinking.

Just checked. It does not.

I just realized that when the congrats scene was on it’s own, it used some scene variables. I’ll need to create all of them again on each scene now that it’s integrated into each level, correct?

Only if they are expected to already hold values at the start of the scene.

If you give them values after the scene starts and the variable doesn’t exist, then GDevelop will create the variable.

1 Like

I figured out why the external layout wasn’t showing up. I had forgoten to use the action, “Create from external layout”.

Now it is showing up.

The other issues now are that the “TimeFromStart” timer keeps moving when showing the time they took on that level on the “congrats” display. I set a pause timer for the same trigger as hitting the finishing line, but it isn’t pausing the timer.

The other issue is that I can’t figure out how to program the button a player can tap to start the next level. I got the replay button to work using the following,

But I was kind of guessing at how to make a “next level” button. And it didn’t work. How do I assign the button so that the program will automatically know what the next level is for that button?

You can’t do that, unfortunately. I understand what you’d like to achieve (increase the number part of the level name). However, you can’t just add 1 to t number component of a string.

(also there’s the closing bracket at the end - there’s no matching opening bracket)

Change the last event of the your events snip to :

How do you get the “+= 1” at the end of changing the global variable?

I can only set it to equal 1 or plus 1.

When I set it to “add 1”, it still just played the same level again.

I’ve got it displayed differently to you (changed in settings). It’s the plus 1 option (make sure you’re adding to a number variable, not a string variable though).

Thanks. I think I had it for a string variable. Now it’s working. But it only seems to work on the first level. I’m very confused by this because all levels are using the same scene events. At the end of the second level it didn’t trigger the external layout.

Also, any thoughts on how I can get the timer to pause since the action I used didn’t work?

There is also a new issue now as well. Originally I had an inbetween scene after the first level to give instructions for some new gameplay aspects on level 2. But using the method of “+ 1” on the global variable, it skips past the instructions scene.

I suppose I could make the instructions another external layout, but I really don’t want to start over on those pages. It would mess up some animations I have and I think would add a lot more problems I’d have to come here to help get help on. What is the easiest way I can, for the first 3 levels, have it go to a scene I specify? I tried creating a new version of the button, and a new version of the external layout and external event, just to use for the first level, but it didn’t work.

I’m so confused right now.

Do you have an action at the start of the second level that creates from the congrats external layout? Because all the congrats layer objects will be deleted when you change scenes.

How are you currently doing it? A screen snip is best here.

Change the events from my previous post to the following (I’m not sure what you’ve named the instruction scene, so I’ve assumed it’s something like “Level2_instructions”) :

I have an external event that all the levels use and it creates the objects from the external layout.
But, I’ve been digging around the scenes and actions, and just realized that level 2 doesn’t have the “CongratsLevel” that I am hiding and showing. Do I have to create that level in each scene? I had just assumed it would be auto created by the external event’s actions.

I figured out what was happening. It was doing everything just right, but since to go from the instructions scene to the playing scene you just had to click anywhere on screen, it was getting triggered by the mouse button still being down on the button for “next” so quickly that I didn’t even see it show the instructions at all. So I changed it to be a specific line of text that has to be clicked to move to the play scene from the instructions and now it works the way I would expect.

Yes, I think you would.

You are referencing 2 different TimeFromStart. “TimeFromStart” is a timer that you’ve created. TimeFromStart() is a function that gives the time elapsed since the scene started.

If you want the elapsed time from your timer, use TimerElapsedTime("TimeFromStart) instead in the second event action.

I added the layer to each scene and that fixed the problem of the external layout not being used.

I tried what you suggested but it didn’t work. I tried again but added a " just before the closed bracket in case that was the issue, but it didn’t work either. I think it may be due to the actions on the following external scene. If you don’t mind taking a look at this to figure out if I need to change some of these actions to make the final display time stop ticking along, I would really appreciate it.

I’d suggest pausing the timer TimeFromStart in that first event in the screen snip. That’s when you want the timer to stop. Then when the level starts, unpause it (or reset it if you want to start from 0 again).