I have a problem using OO Lua, I think its just syntax, but i can’t find any solution so I am posting here.
The OO Lua form I am using is shown below. The button is created as part of the object, ‘initbuttons’ is called to add the event listeners, then when the button is touched the listener function is called but even is nil.
ERROR:
attempt to index local ‘event’ (a nil value)
[lua]mClass = {}
mClass.__index = mClass
object = {}
function mClass.new()
setmetatable(object,mClass)
object.button = display.newImage(…etc
return object
end
function mClass:buttonTouchListener(event)
–this function is called when button is touched, but event is nil
end
function mClass:initButtons()
– this function is called externally to add listener
self.button:addEventListener(“touch” , self.buttonTouchListener)
end[/lua]
any ideas or suggestions would be greatly appreciated. [import]uid: 141923 topic_id: 31565 reply_id: 331565[/import]
