Hey,
Is it possible to perform a certain thing (function) for a specific time for example 2 seconds.
After some research I think it has to do something with frames but not quite sure please explain me how it is done thank you!
Time
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Time
this is basic and probably a really poor example but yea it works lol
function keeptime()
tick = tick +1
if tick > 9 and tick < 10
-- call a function
end
if tick > 10 then
tick = 0
end
end
remember that this is based on revolutions ( how many times the script is called )
change tick = tick +1 to tick = tick +dt if you want per second...
function keeptime()
tick = tick +1
if tick > 9 and tick < 10
-- call a function
end
if tick > 10 then
tick = 0
end
end
remember that this is based on revolutions ( how many times the script is called )
change tick = tick +1 to tick = tick +dt if you want per second...
Re: Time
You can use cron.lua. It's a very simple library, all you need to do is on the love.update function, call update with the clock.
There are plenty of other timer libraries you can use, but the idea is the same for most of them, keep adding up the dt values that come from love.update.
Code: Select all
myEvent = cron.after(5, function() print("This happens after 5 seconds") end)
function love.update(dt)
myEvent:update(dt)
end
Re: Time
HUMP's Timer lib has the function you want: http://hump.readthedocs.io/en/latest/ti ... mer.during
Who is online
Users browsing this forum: Google [Bot] and 0 guests