[SOLVED] Sleep without freezing

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
6l8
Prole
Posts: 1
Joined: Fri Feb 20, 2015 1:23 am

[SOLVED] Sleep without freezing

Post by 6l8 »

When I use love.timer.sleep() it freezes I don't want it to freeze but delay
How can I do that?
I have tried looking in other topics
Last edited by 6l8 on Fri Feb 20, 2015 8:52 am, edited 1 time in total.
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Sleep without freezing

Post by veethree »

love.timer.sleep() pauses the thread, It's not really meant for delaying things. You can implement a simple timer instead.

The following code would print "Hello world" after 3 seconds.

Code: Select all

local time = 3
local cTime = 0

function love.update(dt)
	cTime = cTime + dt
	if cTime  > time then
		print("Hello world")
	end
end
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Sleep without freezing

Post by Jasoco »

Use a Timer library like cron.lua. It'll make it dead simple.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], slime and 5 guests