Hi Corona people,
I’m new to Corona and Lua and come from Java programming, so I currently try to “convert” my Java OOP thinkink to Corona and Lua. I searched quite a while and didn’t found the best practice to define own objects with own functions which are still compatible with the Corona API, e.g. the physics engine.
Let me explain it with some Lua / Pseudocode:
------ Planets.lua extends the Corona Proxy class?!------- local P = {} local planet local function create() planet = display.newCircle( display.contentCenterX + 60, display.contentCenterY + 60, 80 ) -- return new Planet object??? end local function doOwnFunction() -- Do some stuff with "planet" variable end P.create = create return P ------ Main.lua ------ local planets = require("src.planet") local planet1 = planets.create() physics.addBody( planet1, "dynamic" ) -- Object is still compatible with API planet1.doOwnFunction() -- Object is extentable with own code
Is this even the right approach or should I handle this need completely different in Lua?