Difference between revisions of "love.timer.getFPS"

(Minor edit regarding wording and that FPS values are actually averaged and rounded.)
m (fixed grammar and minor rephrasing to lead into a technical term better...)
Line 1: Line 1:
Returns the current amount of frames per second.
+
Returns the current number of frames per second.
  
 
== Function ==
 
== Function ==
Line 11: Line 11:
 
{{param|number|fps|The current FPS.}}
 
{{param|number|fps|The current FPS.}}
 
=== Notes ===
 
=== Notes ===
The returned value is an average of values taken over the last one second, and it is the rounded multiplicative inverse of what [[love.timer.getAverageDelta]] returns.<br>To get instantaneous frame rate values, use <code>1/love.timer.getDelta()</code>, or <code>1/dt</code> if in [[love.update]], with <code>dt</code> given as the parameter.
+
The returned value is an average of values taken over the last one second, and it is one over what [[love.timer.getAverageDelta]] returns, otherwise known as the multiplicative inverse.<br>To get instantaneous frame rate values, use <code>1/love.timer.getDelta()</code>, or <code>1/dt</code> if in [[love.update]], with <code>dt</code> given as the parameter.
 
== Examples ==
 
== Examples ==
 
Display text at the top left of the screen showing the current FPS.
 
Display text at the top left of the screen showing the current FPS.

Revision as of 17:13, 9 May 2020

Returns the current number of frames per second.

Function

Synopsis

fps = love.timer.getFPS( )

Arguments

None.

Returns

number fps
The current FPS.

Notes

The returned value is an average of values taken over the last one second, and it is one over what love.timer.getAverageDelta returns, otherwise known as the multiplicative inverse.
To get instantaneous frame rate values, use 1/love.timer.getDelta(), or 1/dt if in love.update, with dt given as the parameter.

Examples

Display text at the top left of the screen showing the current FPS.

function love.draw()
   love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10)
end

See Also


Other Languages