Pauses the current thread for the specified amount of time.
This function causes the entire thread to pause for the duration of the sleep. Graphics will not draw, input events will not trigger, code will not run, and the window will be unresponsive if you use this as "wait()" in the main thread. Use love.update or a Timer library for that instead.
Available since LÖVE 0.8.0
This behaviour is not supported in earlier versions.
love.timer.sleep( s )
number sNothing.
Removed in LÖVE 0.8.0
This behaviour is not supported in that and later versions.
love.timer.sleep( ms )
number msNothing.
function love.update(dt)
if dt < 1/30 then
love.timer.sleep(1/30 - dt)
end
end This takes into account the time spent updating and drawing each frame.
function love.load()
min_dt = 1/30
next_time = love.timer.getTime()
end
function love.update(dt)
next_time = next_time + min_dt
--rest of function here
end
function love.draw()
--rest of function here
local cur_time = love.timer.getTime()
if next_time <= cur_time then
next_time = cur_time
return
end
love.timer.sleep(next_time - cur_time)
end
© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.timer.sleep