delta_time

The time passed in microseconds between one step and another.

语法:

delta_time


返回: Real(实数)


描述

The purpose of delta timing is to eliminate the effects of the lag or slowness of computers that try to handle complex graphics or a lot of code. It is a value that can be added on to the speed of objects so that they will eventually move at the same speed, regardless of lag. This is achieved in GameMaker Studio 2 by using the read only variable delta_time every step as it measures the time that has passed between one step and the next in microseconds (1microsecond is 1,000,000th of a second). Therefore the variable delta_time can be used to calculate how much faster (for example) a game character has to move to make up for a lag spike in the game.


例如:

speed = spd * (ot - delta_time);

The above code will set the speed of the instance using delta-time to correct for lag. The variable "ot" would be used to hold the previously calculated delta_time value so that the ratio can be used to multiply the base speed value (held in the variable "spd") and so get a consistent speed for the instance.


上一页: Date And Time Functions
Next:get_timer
© Copyright YoYo Games Ltd. 2018 All Rights Reserved