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 .
xefhs
Prole
Posts: 8 Joined: Fri Dec 09, 2011 7:17 am
Post
by xefhs » Sat Mar 10, 2012 2:51 pm
Hi,
I try to find the best way (in other words, optimized to save CPU) to execute a function each defined time.
Code: Select all
increaseCount(2) --Increase the count every 2 secs
Sorry about my English, I'm French.
thelinx
The Strongest
Posts: 857 Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden
Post
by thelinx » Sat Mar 10, 2012 3:54 pm
tentus
Inner party member
Posts: 1060 Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:
Post
by tentus » Sat Mar 10, 2012 4:09 pm
Or, if you don't need something quite that robust:
Code: Select all
function love.load()
timePassed = 0
timeLimit = 2
end
function love.update(dt)
timePassed = timePassed + dt
if timePassed > timeLimit then
timePassed = timePassed - timeLimit
doFunction()
end
end
xefhs
Prole
Posts: 8 Joined: Fri Dec 09, 2011 7:17 am
Post
by xefhs » Sun Mar 11, 2012 12:39 am
cron is very useful, and thanks for the explanations !
Sorry about my English, I'm French.
Users browsing this forum: No registered users and 18 guests