Book Image

Corona SDK Mobile Game Development: Beginner's Guide

By : Michelle M Fernandez
Book Image

Corona SDK Mobile Game Development: Beginner's Guide

By: Michelle M Fernandez

Overview of this book

Table of Contents (19 chapters)
Corona SDK Mobile Game Development Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Valuable variables


Like in many scripting languages, Lua has variables. You can think of a variable as something that stores values. When you apply a value to a variable, you can refer to it using the same variable name.

An application consists of comments, blocks, statements, and variables. A comment is never processed, but it is included to explain the purpose of a statement or block. A block is a group of statements. Statements provide instructions on what operations and computations need to be done; variables store the values of these computations. Setting a value in a variable is called assignment.

Lua uses three kinds of variables, which are as follows:

  • Global variables

  • Local variables

  • Table fields (properties)

Variables take up memory space, which can be limited on various mobile devices. When a variable is no longer required, it is best to set its value to nil so that it can be cleaned quickly.

Global variables

A global variable can be accessed in every scope and can be modified from anywhere...