Just curious: anyone got a feel for which OOP style of “who owns who” is more prevalent? (primarily since messing with Corona metatables is verboten, figure most end up with some such approach eventually)
For example, here’s some commonly encountered approaches, if easier to just say “I do #1”.
Note, i don’t much care if some “framework” or just DIY involved, just the resulting \ *structure between * Lua and Corona objects. If you want to share any “whys” you prefer one over the other, bonus!
- just “tag” display objects with extra properties/methods, no metatable fiddling
fe: aDisplayObject.someCustomProperty = “foobar”
fe: aDisplayObject.someCustomFunction = function(self,params) end
- create “real” (metatable-based) Lua classes, display object “owns” lua object
fe: aDisplayObject.myLuaObject = SomeLuaClass:new()
- create “real” (metatable-based) Lua classes, lua objects “owns” display object
fe: aLuaObject.myDisplayObject = display.newSprite(…
- keep them separate and proxy them to each other “somehow” without “polluting” either
fe: theListOfAllDisplayObjects[“fish”] = display.newSprite(…whatever…)
fe: theListOfAllLuaObjects[“fish”] = FishClass:new(…whatever…)
– implied: they could then proxy each other by same-named key
– or to any degree of ‘more elaborate’:
fe: theProxyTable[aLuaObject] = aDisplayObject
- some other arrangement?
cheers