Search code examples
luacoronasdkmoai

Is it a must to start the class name with a capital letter,in Lua programming (for corona sdk,Moai,..)?


Is it a must to start the class name with a capital letter,in Lua programming (for corona sdk,Moai,..)?

---for example in Player.lua
Player = {}
--flag for player
Player.isHit = false
function Player:new()
    local player = display.newImage("player.png")
    return player
end
return Player

Solution

  • Lua does not have the concept of classes. Lua is a simple language; any variable can store any kind of value. The only naming conventions that Lua requires is that variable names not be language keywords.

    These are conventions that certain Lua libraries or embedded contexts use. But if your library/embedded context has that convention, you should probably abide by it for the sake of consistency.