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 .
Kibita
Prole
Posts: 31 Joined: Tue Dec 29, 2015 7:46 pm
Post
by Kibita » Tue Jul 26, 2016 8:08 pm
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
Post
by Skeletonxf » Thu Jul 28, 2016 12:07 am
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.
Users browsing this forum: Ahrefs [Bot] , Amazon [Bot] , Bing [Bot] , Google [Bot] and 5 guests