This function can be used to set the game speed. You can set this in one of two ways - as either game frames per second (FPS) or as microseconds per game frame (MPF) - using one of the following two constants:
Constant | Description |
---|---|
gamespeed_fps | Sets the game speed using frames per second. |
gamespeed_microseconds | Sets the game speed using microseconds per frame. |
So, for example, a game speed of 30 frames per second would be 33333 microseconds per game frame, which would then be expressed by this function as either:
game_set_speed(30, gamespeed_fps);
or:
game_set_speed(33333, gamespeed_microseconds);
NOTE On Android, if the device's refresh rate cannot be set to the requested game speed, GameMaker will set it to an integer multiple of the requested game speed. If no multiple is available the highest refresh rate available is used and frames are skipped.
game_set_speed(speed, type);
Argument | Type | Description |
---|---|---|
speed | Real | The new game speed (as either FPS or MPF). |
type | Game Speed Constant | The type of method used to set the game speed (see the constants above). |
N/A
if (os_browser == browser_not_a_browser)
{
game_set_speed(60, gamespeed_fps);
}
else
{
game_set_speed(30, gamespeed_fps);
}
The above code checks to see if the game is running in a browser and sets the game speed accordingly as an FPS value.