I’m new to lua and I have some problem with closures. I have a function:
function cell(x,y,s, group)
local myCircle = display.newCircle( x, y, s )
myCircle.la = 1
local myclosure = function()
myCircle.la= myCirle.la + 1
end
timer.performWithDelay( 1500, myclosure, 0 )
return true
end
But when timer callback is executed i’m getting an error:
file.lua:39: attempt to index global 'myCirle' (a nil value)
Does function myclosure ‘see’ variables from function cell ? if not is there any way to get access to them?
You misspelled it. The error actually claims that you attempted to access “myCirle”, not “myCircle”.