I am having trouble with performWithDelay. If I call a function within without passing any variables, then everything is peachy, however whenever I do this:
As I remember it, you can’t pass arguements into functions with the timer.performWithDelay… Only createBricks… You can get around this using Lua closures… Basically a small function that calls another function… So it would be like this…
local closure = function() createBricks(0,0) end
timer.performWithDelay(200 , closure , 10)
I’m pretty sure this is right… Haven’t used one myself in a bit…
As I remember it, you can’t pass arguements into functions with the timer.performWithDelay… Only createBricks… You can get around this using Lua closures… Basically a small function that calls another function… So it would be like this…
local closure = function() createBricks(0,0) end
timer.performWithDelay(200 , closure , 10)
I’m pretty sure this is right… Haven’t used one myself in a bit…
To explain behavior:
Timer.performWithDelay just calls function passed as argument. So if your argument was createBrick(0,0) then timer is trying to do something like this: createBrick(0,0)() which doesn’t work because createBrick probably doesn’t return function (yes, function is executed before it is passed as timer argument). You must pass parametless function as argument, but you pass result of calling
createBrick()