I am very new to Corona SDK and Lua, but I am a very experienced programmer in languages like; c/c++, javascript, php, asp, C# and many others.
I started Corona SDK by creating two very simple games “Simon Says” and “Memory Game”. Which required very little Lua programming. This was very easy with Lua.
My next step was to learn how to do OO with inheritance which is needed if I am going to make bigger projects… but here is where the nightmare begins. Lua is terrible for OO,… it seems more like hacks then anything else. I keep stumbling onto limitation after limitation.
I tried to make a simple object that would inherit from display.newGroup
I would create a “hello world” text and insert it into my object (which I can’t because of my limited knowledge how to create OO with Lua).
Here is a bad example:
GameTimer = { } GameTimer.protoype = { } GameTimer.mt = {} function GameTimer:new() local timer\_new = display.newGroup() --[[setmetatable(timer\_new, self) for k, v in pairs(GameTimer) do timer\_new[k] = v end ]] timer\_new.anchorChildren = true local text = display.newText({ text = "10:00:00", x = 0, y = 0, font = native.systemFont, fontSize = 16, }) text.fill = { 1,1, 1,1 } timer\_new:insert(text) return timer\_new end
apparently my setmetatable is incorrect, but I have no clue what do do? Lua has no natural programming pattern to follow, it all seems hardcoded to fit whatever.
Anyone?
Peter