I have a big game and I scratching my head about how to make the "go back to main menu" feature simple.
The first obvious step is to reset all global variables, but as far as I know all the groups will retain their current activation status if the player doesn't quit the game, which causes problems. I can't find a feature such as "reset all groups to default activation status", do anyone know if it is hidden somewhere? Or is it a workaround?
Worst case scenario I have to review all the code and manually reset hundreds of groups, with possible bugs if I forget just one, which I'd like to avoid.
Thanks in advance for your help!
Develop games in your browser. Powerful, performant & highly capable.
Not sure if this advice will be helpful..
In my game, which is also quite a big project, I have lots of separate event sheets for different things - Audio, Background, Enemies, Shop, Coins etc.
Almost all of them have "Init()" function, which resets static variables, enables/disables groups and does other things like that.
On start of each level I call these functions - BackgroundInit(), EnemiesInit() etc.
This helps to keep things organized.
Changing state for several hundreds of groups at once doesn't seem like a good idea.
If you think it's the only way, you can try this:
Make a list of all groups. (to automate this task you can search for "event-group" tag in .xml files of the project using software like Notepad+)
On start of the game, loop through this list and save the initial state of each group in an array or dictionary.
Then you can use this data to reset all groups to their initial state.
Or you can include the default state into each group's name. For example "Player controls #D", where "#D" at the end means "disabled by default".
Hey, thanks for the reply and the suggestion. In any case it seems to be quite a lot of work to do this simple thing. I guess that's the only way to do it though, so I'll make that list of all groups.