|
|
Module
love.timer
The timer module keeps track of time between frames, so that game
objects can be updated in a FPS-independet fashion. The precision of the
timer is usually 1ms, although this may vary from system to system. Hardware timers
with higher precision are planned, but not implemented at the time of writing.
Functions
Examples
Example 7: Sleeping
function update(dt) -- Sleeps 10ms after each udpate. By doing this, -- CPU time is made available for other processes, -- and your OS will love you for it. love.timer.sleep(10) end
Example 9: Timing code
function load() -- Get time before the code to be timed. t_start = love.timer.getTime() -- Load 10 fonts. for i=12,22 do local f = love.graphics.newFont(love.default_font, i) love.graphics.setFont(f) end -- Get time after. t_end = love.timer.getTime() end function draw() love.graphics.draw("Spent " .. (t_end-t_start) .. " seconds loading 10 fonts.", 50, 50) end
Copyright © 2006-2008 LÖVE Development Team.
|