Game Development Reference
In-Depth Information
function animal:speak()
print(self.says)
end
function animal:move(speed)
self.position.x = self.position.x+speed
end
return animal
end
This would work fine and not cause issues.
cat_01 = animal.new("cat")
Animal namespace. This
namespace. That will thereby eliminate the issues mentioned earlier.
powerful and important in Lua. You'll be reading a lot about them (in some form or other) in most of
the chapters.
Another important concept that we touched upon is the namespace. Namespaces help to
distinguish between the functions available in the main namespace (the global functions) and the
functions in a custom library.
 
Search WWH ::




Custom Search