该函数可用于设置游戏速度。您可以使用以下两个常量之一,通过以下两种方法之一进行设置:每秒游戏帧数(Fps)或每个游戏帧数(Mpf):
常量 | 描述 |
---|---|
gamespeed_fps | Sets the game speed using frames per second. |
gamespeed_microseconds | Sets the game speed using microseconds per frame. |
因此,例如,每秒 30 帧的游戏速度将是每游戏帧 33333 微秒,则该函数可将其表示为:
game_set_speed(30, gamespeed_fps);
or:
game_set_speed(33333, gamespeed_microseconds);
注意 在 Android 上,如果设备的刷新率无法设置为请求的游戏速度,GameMaker 会将其设置为请求的游戏速度的整数倍。如果没有多个可用,则使用可用的最高刷新率并跳过帧。
game_set_speed(speed, type);
参数 | 类型 | 描述 |
---|---|---|
speed | Real | 新游戏速度(以Fps或Mpf表示) |
type | Game Speed Constant | 用于设置游戏速度的方法类型(参见上面的常量)。 |
N/A
if (os_browser == browser_not_a_browser)
{
game_set_speed(60, gamespeed_fps);
}
else
{
game_set_speed(30, gamespeed_fps);
}
上述代码检查游戏是否在浏览器中运行,并相应地将游戏速度设置为Fps值。