Skip to main content

Timer

Description:

  Provides an interface to the user's clock.

step

Type: Function.

Description:

  Measures the time between two frames. Calling this changes the return value of love.timer.getDelta.

Signature:

step: function(): number

Returns:

Return TypeDescription
numberThe time passed (in seconds).

getDelta

Type: Function.

Description:

  Returns the time between the last two frames.

Signature:

getDelta: function(): number

Returns:

Return TypeDescription
numberThe time passed (in seconds).

getFPS

Type: Function.

Description:

  Returns the current frames per second.

Signature:

getFPS: function(): integer

Returns:

Return TypeDescription
integerThe current FPS.

getAverageDelta

Type: Function.

Description:

  Returns the average delta time (seconds per frame) over the last second.

Signature:

getAverageDelta: function(): number

Returns:

Return TypeDescription
numberThe average delta time over the last second.

sleep

Type: Function.

Description:

  Pauses the current thread for the specified amount of time.

Signature:

sleep: function(seconds: number)

Parameters:

ParameterTypeDescription
secondsnumberSeconds to sleep for.

getTime

Type: Function.

Description:

  Returns the value of a timer with an unspecified starting time. This function should only be used to calculate differences between points in time, as the starting time of the timer is unknown.

Signature:

getTime: function(): number

Returns:

Return TypeDescription
numberThe time in seconds. Given as a decimal, accurate to the microsecond.