Dragonfly Cloud is now available on the AWS Marketplace - Learn More

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 function allows you to toggle between fullscreen and windowed mode. Here's how to correctly implement this function:

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

Ensure that your game is set to start in fullscreen by default by placing the fullscreen function in the Create event of an object that initializes at the start of your game. This is usually done in a controller or game manager object.

Moreover, to offer players the option to toggle fullscreen on and off at will, you could link this function to a key press or integrate it within an in-game menu:

// 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 snippet checks if a specific key (in this case, F1) is pressed and toggles the display mode based on the current state, which is queried with window_get_fullscreen(). This function returns true if the window is currently in fullscreen mode, and false otherwise.

It's important to note that switching between display modes might impact the visual presentation of your game, especially if scaling and aspect ratios are not properly managed. It is crucial to have systems in place to adapt to these changes smoothly to ensure a seamless experience for players when they switch modes.

Using these functions correctly will help you manage the fullscreen settings in your GameMaker project effectively. If you encounter issues with these instructions, make sure your version of GameMaker supports these functions, as certain outdated versions might behave differently.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Switch & save up to 80% 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost