Difference between revisions of "love.timer.getAverageDelta"

m
m (Fixed example)
Line 18: Line 18:
 
   -- Display the frame time in milliseconds for convenience.
 
   -- Display the frame time in milliseconds for convenience.
 
   -- A lower frame time means more frames per second.
 
   -- A lower frame time means more frames per second.
   love.graphics.print(string.format("Average frame time: %.3f ms", 1000 * delta) 10, 10)
+
   love.graphics.print(string.format("Average frame time: %.3f ms", 1000 * delta), 10, 10)
 
end  
 
end  
 
</source>
 
</source>

Revision as of 19:45, 11 August 2013

Available since LÖVE 0.9.0
This function is not supported in earlier versions.

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

Function

Synopsis

delta = love.timer.getAverageDelta( )

Arguments

None.

Returns

number delta
The average delta time over the last second.

Examples

Display text at the top left of the screen showing the average time taken to update and draw each frame.

function love.draw()
   local delta = love.timer.getAverageDelta()
   -- Display the frame time in milliseconds for convenience.
   -- A lower frame time means more frames per second.
   love.graphics.print(string.format("Average frame time: %.3f ms", 1000 * delta), 10, 10)
end

See Also

Other Languages