Difference between revisions of "love.timer.sleep"

(Add an example)
(what is this i dont even)
Line 13: Line 13:
 
<source lang="lua">
 
<source lang="lua">
 
function love.update(dt)
 
function love.update(dt)
   if dt < (1/30) then
+
   if dt < 1/30 then
       love.timer.sleep((1/30) - dt)
+
       love.timer.sleep(1000 * (1/30 - dt))
 
   end
 
   end
 
end
 
end

Revision as of 20:56, 10 August 2011

Sleeps the program for the specified amount of time.

Function

Synopsis

love.timer.sleep( ms )

Arguments

number ms
Milliseconds to sleep for.

Returns

Nothing.

Examples

Use sleep to cap FPS at 30

function love.update(dt)
   if dt < 1/30 then
      love.timer.sleep(1000 * (1/30 - dt))
   end
end

See Also


Other Languages