Book Image

Cocos2d-x by Example: Beginner's Guide

By : Roger Engelbert
Book Image

Cocos2d-x by Example: Beginner's Guide

By: Roger Engelbert

Overview of this book

Table of Contents (19 chapters)
Cocos2d-x by Example Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

So what is Lua like?


At the heart of Lua (which means moon in Portuguese), you have the table. You may think of it as being similar to a JavaScript object, only it's much more than that. It plays the part of arrays, dictionaries, enumerations, structures, and classes, among other things. It makes Lua the perfect language to manage large sets of data. You write a script that handles the data, and then keep feeding it different "stuff." An inventory or shop system, an interactive children's book—these types of projects could all benefit from Lua's table-centric power, as they can be built around a fixed template with a data table at its core.

Its syntax, for those not used to a scripting language, can be a little odd, with its dos, thens, and ends. But once you get past this initial hurdle, you'll find Lua quite user-friendly. Here are some of the "oddities" in its syntax:

-- a comment
--[[ 
a 
multiline 
comment 
]]
-- a table declared as a local variable
local myTable = {}
-- the length of...