该函数可用于获取游戏速度,既可以是每秒运行的游戏帧数,也可以是每个游戏帧的微秒数。请注意,这不是实际运行速度Fps值(对于该值,使用fps_real变量),而是游戏将尝试保持每秒的游戏帧数(Fps),或者游戏将尝试保持的每个游戏帧的长度(以微秒为单位)(Mpf)。使用此函数时,需要给出以下常量之一,以确定返回值的类型:
游戏速度常数 | |
---|---|
常量 | 描述 |
gamespeed_fps | Gets the game speed using frames per second. |
gamespeed_microseconds | Gets the game speed using microseconds per frame. |
因此,例如,如果在"游戏选项"中将游戏速度设置为30,并且您使用Fps类型,则该函数将返回30,但如果您使用Mpf,则该函数将返回3333。
game_get_speed(type);
参数 | 类型 | 描述 |
---|---|---|
type | 游戏速度常数 | 用于获取游戏速度的方法类型(参见上面的常量)。 |
if (game_get_speed(gamespeed_fps) != 60)
{
game_set_speed(60, gamespeed_fps);
}
以上代码检查游戏是否以60 Fps的游戏速度运行,如果不是,则设置为60 Fps。