Taking a crack at Classes in Lua

So, after some digging on this infamous medium better know as “A series of tubes” I found the following structure to emulate classes in Lua.

Enemy = {}  
mt = {}  
  
mt.\_\_index = Enemy  
  
function Enemy:new()  
 local bug = display.newImage("bug.png")  
 bug:rotate(90)  
 return setmetatable(bug, mt)  
end  

Which is called in the form of Enemy:new() which returns my displayObject with the meta table on it which in turn lets me define meta-functions. (If I’m already messing something up so far, do let me know :))

Thing is, even calling the “x” property of the returned “bug” results in a reference loop. Which I can kinda visualize but it doesn’t logically make sense in my head.

Any Lua guru’s that can chip in here?

– BLAHBLABHBLAH – decided to check the code exchange and the above is all junk due to my lack of researching Corona’s way first. #headdesk

Is there apart from the OO framework in the Code Exchange by jHocking a recommended way of approaching this from Ansca’s end? As it’s bedtime now I’ll be checking out JH’s method tomorrow :slight_smile:

(still pissed about not looking it up before wasting an hour on it…curse me)

Thanks!
Reinier [import]uid: 53290 topic_id: 12417 reply_id: 312417[/import]