Hello,
Can a menu page, game over page, or failure page be opened on the main scene in GDevelop?
I know we can create a scene for each of these pages, such as a scene for “You Won”.
regards,
Hello,
Can a menu page, game over page, or failure page be opened on the main scene in GDevelop?
I know we can create a scene for each of these pages, such as a scene for “You Won”.
regards,
Absolutely, this is how I always do it because I think it looks much more professional than having a totally separate menu scene. I would only separate them if for example the menu was too complex and creating a performance hit.
There are a few different ways to do it, one easy way is to simply have a single menu object with buttons attached that you can slide on and off screen when you want. Use the Sticker behavior to make several objects follow the main one (i.e. the background of your menu) so you only have to move the one object.
You could also put all of the menu stuff on a unique layer, then hide that layer until you need it.
In either case you will need to decide whether you want to pause the rest of the action while menu is visible, and take into account mouse clicks going through objects. If you click on a button, but there’s something underneath that can also be clicked, both will trigger their events. So you would need a variable to determine if player is viewing menu or not, so that clicking on menu buttons doesn’t also do something in the game.
One advantage of the layer method is that you can change the time scale of specific layers, so you could pause the game by changing time scale to 0 for the action layers but not the menu layers. Another way would be if you are using Physics engine and your only moving objects are all physics objects, you can set the physics time scale to 0.
Thanks, but how should I display the menu on the scene when needed? Should I use the create object function?
Can you explain this one more?
Do you mean that you create a menu at the top of the game page and then hide it?
Exactly - in fact I use the Tween behavior to make it slide on and off screen
You can use a sprite, tiled sprite, or 9-patch as the menu background. Then place whatever buttons, text, etc that you need on the background object. Give them all the Sticker behavior and at the beginning of the scene, Stick them to the menu. Once stuck they will maintain their arrangement in relation to the background, so you can now change the position of the background during the game to either show or hide the menu.
Hope this helps
Now this question comes to me:
If for example we have 10 scene we should do these step for all of them?
Is there any place that we can code for all the game?
thanks
Do you have any opinion on this question?
Write the code for all scenes when necessary instead of writing code for each individual scene, such as the menu.
Yes, an external layout as @jack mentioned is probably your best option here since at the start of each scene you will have to recreate the menu objects.
I would consider doing things the other way around - one scene for the main game, 10 external layouts for the levels. But if your scenes have a lot of differences in the events sheet then it could be a real pain to switch to that method.
Is it really critical for you to have the menu work this way? It sounds like it would be easier to just keep it as a separate scene…
Thanks for your help.