Book Image

Corona SDK Mobile Game Development: Beginner's Guide

Book Image

Corona SDK Mobile Game Development: Beginner's Guide

Overview of this book

Corona SDK is the fastest and easiest way to create commercially successful cross platform mobile games. Just ask Robert Nay, a 14 year old who created Bubble Ball - downloaded three million times, famously knocking Angry Birds off the top spot. You don't need to be a programming veteran to create games using Corona. Corona SDK is the number one tool for creating fun, simple blockbuster games. Assuming no experience at all with programming or game development you will learn the basic foundations of Lua and Corona right through to creating several monetized games deployable to Android and Apple stores. You will begin with a crash course in Lua, the programming language underpinning the Corona SDK tool. After downloading and installing Corona and writing some simple code you will dive straight into game development. You will start by creating a simple breakout game with controls optimized for mobile. You will build on this by creating two more games incorporating different features such as falling physics. The book ends with a tutorial on social network integration, implementing in app purchase and most important of all monetizing and shipping your game to the Android and App stores.
Table of Contents (18 chapters)
Corona SDK Mobile Game Development Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Valuable variables


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

An application consists of statements and variables. Statements provide instructions on what operations and computations need to be done. Variables store the values of these computations. Setting a value into a variable is called an assignment.

Lua uses three kinds of variables: global, local, and table fields.

Global variables

A global variable can be accessed in every scope and can be modified from anywhere. The term scope is used to describe the area in which a set of variables live. You don't have to declare a global variable. It is created as soon as you assign a value to it.

myVariable = 10
print( myVariable )  -- prints the number 10

Local variables

A local variable is accessed from a local scope and usually called from a function or block of code. When we create a block, we are creating...