Hello,
I’ve this very annoying problem and somehow I can’t come up with an solution …so please help.
I have a class which will be instantiated in several modules. Every object of this class has an event listener for a touch event. Only one object can be “alive” at a time so only one event listener exists.
However I can’t figure out how to access “self” inside the callback of the listener (it allows access to the globals of the module but not to the globals of the object, which have different values)
[lua]
–globals
stuff = “init”
function someobj:new()
o = {}
setmetatable(o, self)
self.__index = self
return o
end
function someobj:initStuff()
– setup the touch listener –
Runtime:addEventListener( “touch”, someobj )
self.stuff = “woohoo!”
end
…
function scrollView:touch(event)
print(self.stuff) – this will print “init” and not “woohoo!”[/lua]
so can I specifically register an listener on a specific object? [import]uid: 11772 topic_id: 4631 reply_id: 304631[/import]
