powerTicks = 0
function activePower(dt)
--timeA = a static point in time defined in love.load
timeB = love.timer.getMicroTime() -- ripping
if timeB - timeA == 10 and powerTicks == 0 then
timeB = timeA
powerTicks = 1
else
end
end
function drawPowerTime()
if powerTicks == 1 then
love.graphics.print("##########",200,250)
love.graphics.print("##########",200,260)
love.graphics.print("##########",200,270)
love.graphics.print("##########",200,280)
else
--just for testing...
love.graphics.print(timeB,200,300)
love.graphics.print(timeA,200,290)
end
end
my_timer = Polygamy.timer {
delay = time, -- the delay in seconds before the first occurrence. 0 if not specified
times = integer, -- How many times do you want to execute it? 1 if not specified, 0 = infinite
interval = time; -- the interval in seconds between each repeats. set to "delay" if not specified.
function(times, countdown)
-- do whatever you want to do repeatedly
-- <times> is the number of times the timer has been executed and
-- <countdown> is how many times are left before it expires (0 if infinite)
end
}
my_other_timer = Polygamy.timer{ etc ... }
my_timer:pause()
my_timer:resume(delay)
Polygamy.timer:pause() -- pauses all timers
Polygamy.timer:resume() -- resumes all timers previously active. The ones paused individually are still paused.
Polygamy.timer refers to the default timeline, but you can create new ones, that can be enabled and paused individually.
eventQueue = {
[6]=function() powerTicks = true end,
[11]=function() --[[do something awesome]] end
}
totalTime = 0
function update(dt)
totalTime = totalTime + dt
for time, event in pairs(eventQueue) do
if time < totalTime then
event()
eventQueue[time] = nil
end
end
end
Wow, excellent support all around. Thanks guys.
The event system seems extremely practical for what my team is working on.
I'll definitely look into working it in.