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.

1
2
3
4
5
6
7
8
9
10
Enemy = {}
mt = {}
 
mt.__index = Enemy
 
function Enemy:new()
        local bug = display.newImage("bug.png")
        bug:rotate(90)
        return setmetatable(bug, mt)
end
views:1460 update:2011/9/28 21:38:26
corona forums © 2003-2011