Game menu

Hi I would like to have a menu in my sim that opens and closes when M is pressed. I want the menu to start closed and then allow it to be opened at any time during run time.

Can anyone help/provide helpful links on where I could learn how to implement this?

1 - Managing a menu layout you could use defolds gui component. GUI component

2 - For Handling input like when pressing the M key there are a few things to think about

3 - Lets say you have a gui menu now and you can press M have a script ready and want the gui to pop up, There is more than one way you can do this, a simple way is to hide the menu by having a root node that holds all your gui nodes and disable it from being visible and taking any input and when M key is pressed enable it. A little more advanced way would be to use collection proxies, In this case lets say you want to pause the game while the menu pops up. Then you would want your active game to be loaded via a collection proxy and your menu should be a proxy as well. The active game can be paused using set_time_step then you can load the proxy gui menu via collection proxy. Collection proxies are a nice way to load an unload content and have control of the time step.

Welcome to Defold and hopefully you find these links helpful, cheers!

5 Likes

Thank you!

Just a question with this. If I had my menu as a proxy would the menu settings be saved so that when close and open the menu again there by unloading and loading the proxy, all the settings would be the same? Also is it possible to use the go.set and go.get to communicate and change property values between scripts from the two different

No, you need to save the state yourself and restore it when you load the menu again. You can use sys.save() and sys.load() to save and load a Lua table with settings.

Check out Defold Assets Portal too :blush:

Perhaps you can find there something easy to use and useful like for example:

For gui:
Gooey - relatively easy and simple
Druid - very powerful and versatile, might be a little difficult to get in, but worth it
DearImGUI - very powerful, but requires getting familiar with ImGUI
Nuklear - same as above, but Nuklear

For screen managing:
Monarch

For saving:
Defsave
Defold Saver
Defold Persist

2 Likes