This may sound stupid, but how do you use the timer in defold.
I am trying to make the sprite i have fade by ‘tinting’ it by 0.1 every 0.5 second.
local splash_timer = timer.delay(0.5, true, tint_background())
function tint_background(self, handle, time_elapsed)
local i = 1
if(i <= 10) then
go.set("#logo", "tint.w", (0.1*i))
i = i + 1
else
timer.cancel(handle)
end
end
The error message I keep getting is: ERROR:SCRIPT: Unable to create a timer, the lua context does not have a timer world
I don’t get what I am doing wrong after reading Timer Reference.
I’m not entirely sure about what kind of effect you’re after, but perhaps you could try something like this:
local function anim()
go.animate("#sprite", "tint.w", go.PLAYBACK_ONCE_PINGPONG, 0.0, go.EASING_INOUTSINE, 0.5, 1.0, anim)
end
function init(self)
anim()
end
No, I haven’t been using Defold that long (this is my first project) and so far I have not messed with go.animate yet; but thank you for the suggestion, I will look into it.
Sorry, still having trouble with this. I need to pass some variables onto a function. This code is not working. bad argument #3 to ‘delay’ (function expected, got no value):
timer.delay(1, false, type(self, self.cola[1], "STATE:", " SYSTEM CHECK"))
When i do this, everything works:
type(self, self.cola[1], "STATE:", " SYSTEM CHECK")
but I can’t get it working with the timer. Any help? Thanks!
I was just looking for ways to make timers in defold when I came across your post I was just wondering what unit is used to measure time in the timer.delay function