pausegame-maker-studio-2

How do I check whether I have changed rooms in Game Maker Studio 2?


So I have been working on a pause menu for a game I have been working on with Game Maker Studio 2.

Whenever I change rooms (like going to the options room or main menu) the pause menu stays and everything looks very weird and overlapped. Is there a way to check if I have changed rooms to destroy the objects the menu is made up of

(So like if (room has changed) {Delete pause menu})*

If someone could give me the correct syntax that would be awesome!

Thanks.

*I have sorted out deleting the menu, just need to know what to put in the if statement


Solution

  • For my game, I've done a check if the room is the same as the room in the main menu/options menu, or make a check that the pause menu only appear when it's not the main menu/options menu.

    var roomname = room_get_name(room);
    if (roomname != r_mainmenu && roomname != r_optionsmenu) 
    {
        //draw pause menu
    }
    

    Another idea is to hide the pause menu once you go back to the main menu.