Hi folks,
so far I don’t really understand the difference of a table and a function listener. What is it? When should I use one of them, instead the other?
Michael [import]uid: 5712 topic_id: 821 reply_id: 300821[/import]
Hi folks,
so far I don’t really understand the difference of a table and a function listener. What is it? When should I use one of them, instead the other?
Michael [import]uid: 5712 topic_id: 821 reply_id: 300821[/import]
A “function listener” does not reference a table, where the “table listener” does. The syntax is slightly different too – “object.listener” for a function and “object:listener” for a table. A “table listener” is generally called a method, and a “function listener” is usually called a “function”.
What does that mean? A method is a function that operates on an object, and in Lua has a first parameter which is the object. But with the “method” syntax (the colon operator ":), the object parameter is hidden. The object parameter is called “self” inside the method.
For further reference please see Programming in Lua, Chapter 16: Object-Oriented Programming, http://www.lua.org/pil/16.html
[import]uid: 54 topic_id: 821 reply_id: 1799[/import]
Thanks buzz, makes it more clear. I am new to LUA and so was wondering. I thought it was related to Corona. [import]uid: 5712 topic_id: 821 reply_id: 1819[/import]
Why was the event listener added to the table instead of just using a function in the example “animation 3”?
I created a function barry (event)
– copied the body of the code from collection:enterFrame(event) to barry
In addEventListener changed collection to barry
Code executes the same [import]uid: 6069 topic_id: 821 reply_id: 1862[/import]