Question: How do you enable fullscreen in GameMaker?

Answer

To enable fullscreen in GameMaker, you can use the built-in GameMaker Language (GML) function window_set_fullscreen(). This allows you to toggle between fullscreen and windowed mode. Here's how you can use this function:

// Set the game to fullscreen window_set_fullscreen(true); // To switch back to windowed mode window_set_fullscreen(false);

To set your game to start in fullscreen by default, place the fullscreen function in the Create event of an object that is initialized at the start of your game, such as a controller or game manager object.

Additionally, if you want to provide players with the option to toggle fullscreen on and off, you could tie this function to a key press or an in-game menu option:

// Example code for toggling fullscreen with a key press if (keyboard_check_pressed(vk_f1)) // vk_f1 can be replaced with any desired key { // Toggle between fullscreen and windowed mode window_set_fullscreen(!window_get_fullscreen()); }

This checks for a key press and toggles the display mode accordingly. The window_get_fullscreen() function returns whether the window is currently in fullscreen mode (true) or not (false).

Be aware that changing the display mode might affect the appearance of your game depending on how you've handled scaling and aspect ratios. Make sure you have systems in place to handle these changes to ensure that switching modes provides a seamless user experience.

Using these functions appropriately will allow you to control the fullscreen state of your GameMaker project.

Was this content helpful?

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.