Page 1 of 1

Change HUMP Time delay

Posted: Tue Jul 26, 2016 8:08 pm
by Kibita
Hello!

What are the best way to change the delay time of a Hump Timer function? I tried to implement a function inside Timer.lua like this:

Code: Select all

function Timer:delayTime(handle, delay)
	self.functions[handle] = delay
end
and in the main game file:

Code: Select all

local time = 1.5
spawn = Timer.every(time, function()
     table.insert(obstacle, Obstacle.new(Push:getWidth() * 1.25, love.math.random(0, Push:getHeight()), -500, love.math.random(-5, 5)))
end)

Timer.every(5, function()
     time = time - 0.3
     Timer.delayTime(spawn, time)
end)
but I get the following error: attempt to call field 'delayTime' (a nil value)
Anyone already managed to do this sort of thing?

Thank you!

Re: Change HUMP Time delay

Posted: Thu Jul 28, 2016 12:07 am
by Skeletonxf
Timer:delayTime() is equivalent to Timer.delayTime(self)

In your code above you define the method using : but then you call it with . which I'm guessing is a typo where you meant : so currently the function you're calling doesn't exist so the field is a nil value.