display_set_timing_method

This function sets the timing method to be used for rendering your game.

The method can be one of the following constants:

Display Timing Method Constant
ConstantDescription
tm_sleepThe sleep margin value is the main timing method
tm_countvsyncsVsync timing is the main timing method (default for all supported platforms)
tm_systemtimingSystem timing is the main timing method

The vsync timing method uses the target platform's support for vertical synchronisation to provide an anchor for the game's render timing calculations, while setting the mode to sleep margin will just try to ensure that each frame lasts for the correct amount of time (say 1/30th or 1/60th of a second) by waiting or sleeping. In general the default vsync timing will give the smoothest results, but note that when using the vsync method, the sleep margin values are still relevant, although it will have a reduced impact and we recommend keeping it at its default value when using this method.

By default on all platforms except PS4, Ubuntu and HTML5, GameMaker will use the vsync timing method, while on the unsupported platforms, only sleep margin timing can be used.

Certain Android devices make use of specific framerates. When running on these devices you may want to use the system timing method. This method removes all of GameMaker's sleeps and game speed control and allows the game speed to be set by the system.

If you wish to set the sleep margin you can do so using the function display_set_sleep_margin and you can find which timing method is currently being used with the function display_get_timing_method.

 

Syntax:

display_set_timing_method(method);

ArgumentTypeDescription
methodDisplay Timing Method ConstantThe timing method to use (see the list of constants, above)

 

Returns:

N/A

 

Example:

if (display_get_timing_method() != tm_sleep)
{
    display_set_timing_method(tm_sleep);
    if (display_get_sleep_margin() != 20)
    {
        display_set_sleep_margin(20);
    }
}

The above code will check the timing method and if it's not set to tm_sleep it will be set to that and the sleep margin set to 20.