Lua has some diverse usage, from AI, robotics, 3D shaders, game extensions, or writing games. As such there are a variety of ways to do OOP in Corona. Specifically:
- Classes
- Packages
- Access Modifiers/Namespaces/Encapsulation
- Inheritance
- Polymorphism
- “dealing” with scope
Below, I’ll show you how I do classes and packages in Corona SDK. I cover how to extend core Corona classes, what you can/can’t do, and how to implement classes, packages, & inheritance in Lua. I also briefly cover some of the OOP alternatives and compare/contrast why I chose t3h closure way.
I do not cover, nor use metatables. If you can live without prototype in JavaScript, you’ll do just fine using only closures in Lua. I’ll give you some links at the bottom for using metatables to accomplish OOP in Lua.