Rooms

Rooms are where everything happens in your game. You create them in the IDE using The Room Editor or at runtime using the functions under Modifying Rooms.

Any GameMaker game must have at least one room in it for it to run, but you may need many more depending on the type of game and how you structure your project. By default, a new GameMaker project has a single room added to it.

This section has all the general GML functions and variables related to rooms, for getting information about them as well as for setting certain properties within them.

Function Reference

Global

The following global variables and functions can be used for getting basic information about any given room:

NOTE The variables listed above will not be valid in a script, as scripts are executed before the first room is loaded.

This only applies to code written at the root of a script, but not to functions created inside scripts, as those functions can be executed at any time during the game.

Information

You can also use the following functions to find out if a room exists, get its name (as defined in The Asset Browser) and general info: 

Switching Rooms

Modifying Rooms

NOTE These functions should never be run from within the room that you wish to change, but rather be run from an instance in another room first.

NOTE If you change any room asset in this way, the change is permanent and will be maintained for the entire duration of the game, even if you call the room_restart function (closing and restarting the game will reset the room properties though).

Layers and Elements

Filters and Effects

IMPORTANT When creating room layers you can have multiple different element types on one layer. So, for example, you may have a layer for enemies, and on that layer have the enemy instances as well as certain sprite assets that are only related to that enemy. Or you could have a background element with a tile map element to create the look of a room. This is not permitted in The Room Editor, but when creating things dynamically you can do this, which is why functions like layer_get_all_elements exist.