Change HUMP Time delay

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
User avatar
Kibita
Prole
Posts: 31
Joined: Tue Dec 29, 2015 7:46 pm

Change HUMP Time delay

Post 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!
Skeletonxf
Citizen
Posts: 87
Joined: Tue Dec 30, 2014 6:07 pm

Re: Change HUMP Time delay

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 46 guests