Create 2D Mobile Games with Corona SDK
eBook - ePub

Create 2D Mobile Games with Corona SDK

For iOS and Android

  1. 190 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Create 2D Mobile Games with Corona SDK

For iOS and Android

About this book

Corona SDK is one of the most powerful tools used to create games and apps for mobile devices.

The market requires speed; new developers need to operate quickly and efficiently. Create 2D Mobile Games with Corona SDK gives you the tools needed to master Corona - even within the framework of professional constraints. A must-read guide, this book gives you fast, accurate tips to learn the programming language necessary to create games. Read it sequentially or as an FAQ and you will have the tools you need to create any base game before moving on to advanced topics.

The tutorial-based format:

  • Contains step-by-step directions complete with coding and screenshots
  • Is filled with tutorials, tips, and links to useful online resources
  • Includes a comprehensive companion website featuring online exercise files to practice coding, full build samples from the text, additional book details, and more!

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Create 2D Mobile Games with Corona SDK by David Mekersa in PDF and/or ePUB format, as well as other popular books in Computer Science & Digital Media. We have over one million books available in our catalogue for you to explore.

Information

fig0001

Part 1
Lua

Introduction to Script Programming With Lua

Before getting to the heart of the matter (coding!), let’s learn what Lua means, what a programming language is, and two tips to code like a pro.

Moon

Lua means “moon” in Portuguese. It’s pronounced “loo-ah” and not “L.U.A.” It was created in Brazil in 1993 and is now available for a wide variety of systems.
Corona SDK uses Lua as its programming language. Because Lua is very easy to learn, it has allowed Corona SDK to become one of the most accessible tools to create mobile games and applications.

A Script Is a Shopping List

Lua is a programming language, and more precisely, a scripting language.
Think of a typical shopping list:
  • look for butter at the store
  • if there is no butter, buy margarine
  • go back home
A script is no more than a shopping list for a computer!
Here is an example of our shopping list in Lua code:
fig0002
It’s not terribly realistic, but it’ll help you to understand what a scripting language is.

Comments

Sometimes you’ll need to explain something in your code that isn’t part of the code itself. For example, leaving a note to yourself about something you have to remember, or providing information to others who might read your code.
To insert a comment just do this:
fig0003
If the comment is long, do it like this:
fig0004

Some Advice Regarding Comments

  • Use comments often! Several weeks or months later, you’ll be happy to find these helpful reminders.
  • A comment needs to provide information, not just repeat what the code already explains by itself. An example of a redundant comment would be:
    ifig0001.webp
  • A comment is useful to deactivate a line of code temporarily. For example:
    ifig0002.webp
  • Remove a comment when it is no longer valid.

Traces

On many occasions, you’ll need to display something that’s not for your users, but only for you. A kind of “I was here!” to check if your code is doing what you expect. (Yes, the code isn’t always obedient!)
Here is how to display a trace:
ifig0003.webp
This instruction will display “David was here!” in the console when this instruction is executed.
The console is a kind of ticker that’s essential to your survival.
ifig0004.webp
TOP TIP: Traces are the best and simplest way to discover bugs and fix them. It’s like having a spy in your code! You’ll learn more about traces in the chapter addressing debugging.

That’s All

That’s enough to start. Let’s now look at Lua in detail!

Get Prepared

We all love action. So, before we learn anything, let’s install Corona SDK! You’ll then be ready to enter the code from the examples and test them.

Installing Corona SDK

Corona SDK is, as its name suggests, a software development kit: a mix of tools that allow developers to create certain applications.
To enter and test our code, we’ll use the Corona Editor (which is based on a text editor called Sublime Text 2). We call this tool an IDE (Integrated Development Environment), from which you’ll enter code, compile, and launch your apps for testing.
Sublime Text is an amazing tool, and it’s the best choice from my point of view. You can use any text editor you like, of course, but you won’t get the automated features such as completion, compiling, and so forth.
Installing the SDK is simple. Just follow the officially documented steps according to your operating system.

Installing Corona SDK for Mac OS X

http://docs.coronalabs.com/guide/start/installMac/index.html

Installing Corona SDK for Windows

http://docs.coronalabs.com/guide/start/installWin/index.html
Everything working fine? Now it’s tim...

Table of contents

  1. Cover
  2. Half Title
  3. Title
  4. Copyright
  5. Contents
  6. Acknowledgments
  7. Part 1: Lua
  8. Part 2: Display
  9. Part 3: Move
  10. Part 4: Advanced Features
  11. Part 5: To the Stores
  12. Part 6: Epilog
  13. Index