Search icon CANCEL
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Learning Hub
Free Learning
Arrow right icon
Save more on purchases! Buy 2 and save 10%, Buy 3 and save 15%, Buy 5 and save 20%
Corona SDK Mobile Game Development: Beginner's Guide
Corona SDK Mobile Game Development: Beginner's Guide

Corona SDK Mobile Game Development: Beginner's Guide: You don't need to be a programming whiz to create iOS and Android games. You just need this great hands-on guide to Corona SDK, which teaches you everything from game physics to successful marketing.

$32.99 $9.99
Book Apr 2012 408 pages 1st Edition
$32.99 $9.99
$15.99 Monthly
$32.99 $9.99
$15.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now
Table of content icon View table of contents Preview book icon Preview Book

Corona SDK Mobile Game Development: Beginner's Guide

Chapter 1. Getting Started With Corona SDK

Before we jump right into coding some simple games, we need to install and run the necessary programs that will make our applications come to life. Corona SDK is primarily a 2D development engine. If you've had experience developing for iOS or Android, you will find the experience working with Corona refreshing and simple to use. In no time you'll be creating finished products to distribute on the iPhone App Store and Google Play Store.

In this chapter, we will:

  • Set up Corona SDK on Mac OS X and Windows

  • Install Xcode for Mac OS X

  • Create a Hello World program in two lines

  • Add devices in the iOS Provisioning Portal

  • Load an application to an iOS device

  • Load an application to an Android device

Downloading and installing Corona

You have the option of choosing the Mac OS X or Microsoft Windows operating system to develop on. Keep in mind the following system requirements required to run the program.

If you are installing Corona for Mac OS X, be sure that your system is as follows:

  • Mac OS® X 10.6 or later

  • An Intel-based system that runs Snow Leopard or Lion

  • 64-bit CPU (Core 2 Duo)

  • An OpenGL 1.4 or higher graphics system

If you are running Microsoft Windows, be sure that your system is as follows:

  • Windows 7, Vista, or XP operating system

  • 1 GHZ processor (recommended)

  • 38 MB of disk space (minimum)

  • 1 GB of RAM (minimum)

  • OpenGL 1.3 or higher graphics system (available in most modern Windows systems)

Time for action – setting up and activating Corona on Mac OS X

Let's begin by setting up Corona SDK on our desktop.

  1. If you haven't downloaded the SDK, please do so at: You will have to register as a user before you can access the SDK.

  2. The file extension for any Mac program should end in .dmg, otherwise known as an Apple disk image. Once you've downloaded the disk image, double-click on the disk image file to mount it. The name should be similar to CoronaSDK.dmg.

    Once it is loaded, you should see the mounted disk image folder as shown in the following screenshot:

  3. Next, drag the CoronaSDK folder into the Applications folder. This will copy the contents of the Corona folder into /Applications. You will be prompted to enter an administrator password if you are not the main administrator of the account. You will be able to see the CoronaSDK folder in /Applications once it has been successfully installed.

    For easy access to the folder's contents, create an alias by dragging the CoronaSDK folder to the Dock of your Mac desktop.

    First time Corona SDK users will have to perform a quick and easy one-time authorization process before it canbe accessible.


    You must be connected to the Internet to complete the authorization process.

  4. Launch the Corona Simulator in the SDK folder.

  5. Assuming this is your first time, you will be presented with an End-user License Agreement (EULA). Once you have accepted the agreement, enter the e-mail you used to register for Corona and password to activate the SDK. Otherwise, click Register to create an account.


    If you register with Corona as a trial user, there is no fee to develop on iOS and/or Android devices. Developers that would like to publish their applications on the App Store or Google Play need to purchase the Corona SDK subscription on the website in order to do so at:

  6. Upon successful login, you will get a confirmation dialog to show that the SDK is ready to use as shown in the following screenshot:

  7. Click on the Continue button and you'll be presented with the Welcome to Corona screen as shown in the following screenshot:

What just happened?

Setting up Corona SDK on your Mac operating system is as simple as installing any other dedicated Mac program. After you have authorized the SDK on your machine and logged in with your e-mail and password it will be ready for use. From here on out, every time you launch Corona, it will automatically log in to your account. You will notice that you are greeted with a Corona SDK screen when this happens.

Time for action – setting up and activating Corona on Windows

Let's set up Corona SDK on our desktop.

  1. Download Corona SDK from the following URL: You will have to register as a user before you can access the SDK.

  2. The file extension for the Windows version of Corona should end in .msi, otherwise known as a Windows Installer, a component of Windows made for installing programs by Microsoft. Double-click on the file. The filename should be similar to CoronaSDK.msi.

  3. Follow the onscreen directions for installation.

  4. Corona will install directly to your Programs folder by default. On Microsoft Windows, select Corona from the list of Programs in your Start menu or double-click the Corona icon on the desktop. Upon successful activation, you should begreeted with the following screen:


    The process to activate the SDK should be the same as that of the Mac procedure once you launch Corona for the very first time.


    If you run into issues with images not displaying properly, check to see if you're using an up-to-date OpenGL graphics driver that is 1.3 or higher.


    Be aware that Corona SDK on Windows can only build for Android devices, not for iOS devices (iPhone, iPad, or iPod Touch). A Mac can only build for iOS devices in Corona but can also build applications for Android.

  5. To create device builds, Java 6 SDK needs to be installed on your PC. You will need to go to the JDK download page: and click the Download button under the Java SE 6 option.

  6. On the next page, select the Accept License Agreement radio button and then click on the Windows x86 link to download the installer. You will be asked to log in or create a user account on the Oracle website if you don't already have one.

  7. As soon as the JDK is downloaded, run the installer. Once installed, you'll be able to create device builds for Android on your PC.

What just happened?

Installing the SDK on Windows has a different setup to that of the Mac OS X. While executing the installer file, Windows will automatically present a designated location to install the application such as the Programs folder so you won't have to manually choose a destination. Upon a successful installation you will see the Corona SDK icon on your desktop for easy access or highlighted in the Programs list in the Start menu, assuming you're accessing it for the first time. When you authorize Corona on your machine and sign in with your login information, it is ready for you to use and will lo in automatically every time it is launched.

Using the simulator on Mac and Windows

On Mac OS X, launch Corona SDK by either selecting Corona Terminal or Corona Simulator from the Applications Directory. Both selections will access the SDK. The Corona Simulator will only open the simulator. The Corona Terminal will open both the simulator and terminal window. The terminal is helpful for debugging your programs and displays simulator errors/warnings and print() messages.

On Microsoft Windows, select the Corona SDK folder and click on Corona Simulator from the list of Programs in your Start menu or double-click the Corona icon on the desktop. (The simulator and terminal are always opened together if you are using Windows).

Let's go over the useful contents contained in the Corona SDK folder (located in Applications/Corona SDK on Mac and Start/All Programs/Corona SDK on Windows:

  • Debugger (Mac)/Corona Debugger (Windows)—Tool for finding and isolating issues in your code.

  • Corona Simulator—The environment used to launch your application for testing. It simulates the mobile device you're developing on your local computer. (On Windows, it will open both the simulator and terminal).

  • Corona Terminal—Launches the Corona Simulator and opens a Terminal window to display error/warning messages and print() statements. It is very helpful for debugging your code (only on Mac).

  • Simulator—Has the same properties as Corona Terminal, but called from the command line (only on Mac).

  • SampleCode—A set of sample applications to get you started with Corona. Contains code and art assets to work with.

The Corona SDK window opens by default when you launch the simulator. You can open a Corona project in the simulator, create a device build for testing or distribution, and view soe example games and apps to get you familiar with the SDK.

Time for action – viewing a sample project in the simulator

Let's take a look at the HelloPhysics sample project in the simulator:

  1. Click on Simulator in the Corona SDK window.

  2. In the Open dialog that appears, navigate to Applications/CoronaSDK/SampleCode/Physics/HelloPhysics (Mac) or C:\Program Files\Ansca\Corona SDK\Sample Code\Physics\HelloPhysics (Windows). On Mac, click Open and it will automatically open main.lua. On Windows, double-click on main.lua to open the file. The HelloPhysics application opens and runs in the Simulator.

What just happened?

Accessing the SDK through the Corona Terminal or Corona Simulator depends on your preference of action. Many Mac users prefer to use the Corona Terminal so they can track messages outputted in the terminal, especially for debugging purposes. When you launch the SDK through the Corona Simulator, the simulator will display, but not the terminal window. When Windows users launch the Corona Simulator, it will display both the simulator and terminal windows. This is nice to use when you want to play around with any of the example applications that are provided by Corona.

The main.lua file is a special filename that tells Corona where to start in a project folder. This file can also load other code files or other program resources such as sounds or graphics.

When you launch the HelloPhysics application in Corona, you will observe a box object fall from top of the screen in the simulator and collide with a ground object. The transition from launching the main.lua file to viewing the results in the simulator are almost immediate.

Have a go hero – use a different device shell

As you start getting familiar with the Corona Simulator, whether you're in Windows or Mac OSX, a default device is always used when you launch an application. Windows uses the Droid as the default device, while the Mac OS X uses the regular iPhone. Try launching the sample code on a different device shell to view the difference in screen resolution in all the devices the simulator has available.

When porting builds to more than one platform, you'll have to consider the variety of screen resolutions in both iOS and Android devices. A build is a compiled version of all your source code converted into one file. Having your game build configured for multiple platforms broadens the audience reach for your application.

Choosing a text editor

Corona does not have a designated program editor to code in so you will have to find one that suits your needs.

For Mac OS, TextWrangler is a good one and free too! You can download it at Other text editors such as BBEdit at and TextMate at are great, but you will need to purchase those in order to use them. TextMate is also compatible with the Corona TextMate Bundle:

For Microsoft Windows Notepad++ is recommended and can be downloaded at or Crimson Editor at Both editors are free.

Any text editor, such as TextEdit for Mac or Notepad for Windows, that is already included in each operating system works as well, but it'll be easier to work with one that is designed for programming. For Corona, using an editor that supports Lua syntax highlighting will work the best when coding. Syntax highlighting adds formatting attributes to keywords and punctuation in a way that makes it easier for the reader to separate code from text.

Developing on devices

Apple's developer kit Xcode or the Android SDK is not necessary to download if you only want to use the Corona Simulator. In order to build and test your code on an iOS device (iPhone, iPod Touch and iPad), you will need to sign up as an Apple Developer and create and download provisioning profiles. If you want to develop on Android, you don't need to download the Android SDK unless you want to use the ADB tool to help with installing builds and viewing debug messages.

The trial version of Corona Simulator allows building Adhoc (for iOS) and Debug builds (Android) for testing on your own devices. The builds will contain a Trial User message box when the app runs on the device. You will need to purchase a Corona Subscription if you want to build for Apple's App Store or Android's Google Play Store. Corona Subscribers also get the benefit of subscriber-only features such as access to Daily Builds, Subscribers Only areas on the Corona forums and LaunchPad.

Time for action – downloading and installing Xcode

In order to develop any iOS application you will need to enroll in the Apple Developer Program, which costs $99 a year, and create an account on the Apple website

  1. Click on the Enroll Now button and follow Apple's instructions to complete the process.

  2. When you have completed your enrollment, click on the iOS link under the section marked Dev Centers.

  3. If you are using Snow Leopard, scroll down to the Downloads section and download the current Xcode. If you are using Lion, you can download Xcode in the Mac App Store.

  4. Once you have fully downloaded Xcode, double-click on the .mpkg Installer package (icon is an open brown box). By default, Xcode will install in the folder /Developer. You will be asked to authenticate as an administrative user.

  5. Aftr you have entered your credentials, click on the OK button to complete the installation.

  6. When you have installed the Xcode developer tools, you can access the documentation by launching Xcode and choosing any of the items in the Help menu. Developer applications such as Xcode and Instruments are installed in /Developer/Applications. You can drag those following app icons to your Dock for convenient accessibility.

What just happened?

We just went through the steps of how to install Xcode to Mac OS X. By enrolling in the Apple Developer Program, you will have access to up-to-date development tools on the website. Remember that to continue being an Apple Developer you have to pay a fee of $99 annually to keep your subscription.

The Xcode file is quite large so it will take a bit of time to download depending on how fast your Internet connection is. When your installation is complete, Xcode will be ready to go.

Time for action – creating a Hello World application in two lines of code

Now that we have the simulator and text editors set up, let's start making our very first Corona program! The first program we will be making is called Hello World. It is a traditional program that many people learn when starting a new programming language.

  1. Open your preferred text editor and type the following lines:

    textObject = display.newText( "Hello World!", 50, 40, native.systemFont, 36 )
    textObject:setTextColor( 255,255,255)
  2. Next, create a folder on your desktop called Hello World. Save the preceding text as a file named main.lua to the location of your project folder.

  3. Launch Corona. You will be greeted with the Corona SDK screen. Click on Simulator and navigate to the Hello World folder you just created. You should see your main.lua file in this folder as shown in the following screenshot:

  4. On Mac, click on the Open button. On Windows, select the main.lua file and click the Open button. You'll see your new program running in the Corona Simulator:

Time for action – modifying our application

Before we dive into more complex examples, let's alter some minor things in your program.

  1. Let's alter the second line of main.lua to display as follows:

    textObject = display.newText( "Hello World!", 50, 40, native.systemFont, 36 )
    textObject:setTextColor( 124,252,0 )
  2. Save your file and go back to the Corona Simulator. The simulator will detect a change from your file and automatically re-launch with the new changes. If the simulator doesn't re-launch automatically upon saving your file, press Command + R (Mac)/Ctrl + R (Windows).


    As you continue learning more Corona functions, you'll notice that some of the text values will be optional. In this case, we need to use all five values.

Time for action – applying a new font name to your application

Now let's play around with the font name.

  1. Change the first line to the following code:

    textObject = display.newText( "Hello World!", 50, 40, "Times New Roman", 36 )
  2. Be sure to save your main.lua file after making any alterations, then press Command+R (Mac)/Ctrl+R (Windows) in Corona to re-launch the simulator to view the new font. If you're using a Mac, usually the simulator automatically re-launches after saving your file or it may ask you if you want to re-launch the program.

What just happened?

You have now made your first complete mobile application! What's even more amazing is that this is a completed iPhone, iPad, and Android application. This two-line program will actually install and run on your iOS/Android device if you were to create a build. You have now seen what the basic workflow in Corona is like.

If you take a look at line 2 in your main.lua file you will notice that setTextColor alters the color of the text for Hello World!.

Colors are made up of three sets of RGB numbers representing the amount of red, green, and blue contained within a color. They are displayed with three numbers with values ranging from 0 to 255. For example, the color black would be ( 0,0,0 ), blue would be ( 0,0,255 ), and the color white ( 255,255,255 ).

Continue playing around with different color values to see the different results. You can see the alterations to the code in the simulator when you save your main.lua file and re-launch Corona.

When you view the first line from the main.lua file you will notice that newText() is called by textObject, a name that is then used to reference the display text. The newText() function returns an object that will represent the text on the screen. newText is part of the display library.

When you want to access the display property of newText, type in display.newText. The two numbers after Hello World! control the horizontal and vertical positions of the text on the screen in pixels. The next item specifies the font. We used the name native.systemFont, which by default refers to the standard font on the current device. For example, the iPhone's default font is Helvetica. You can use any standard font name such as Times New Roman (used in the preceding example). The last number used is the font size.

Have a go hero – adding more text objects

Now that you're starting to get a taste of coding, try applying the following in your current project file:

  • Create a new display object using a different font and text color. Display it below the Hello World! text. Hint: Make sure your new text object has a different object name.

  • Continue changing values of the current display object, textObject. Alter the x and y, the coordinates, the string text, the font name, and even the font size.

  • While the object setTextColor( r,g,b) sets the color of the text, there is an optional parameter you can add that controls the opacity of the text. Try using the object setTextColor( r, g, b [, a]). The values available for a also range between 0 to 255 (255 is opaque, which is the default value). Observe the results of your text color.

Testing our application on an iOS device

If you are only interested in testing the application on an Android device, please skip past this section of the chapter to Testing Our Application on an Android Device. Before we can upload our first Hello World application on an iOS device, we need to log in to our Apple Developer account so we can create and install our signing certificates on our development machine. If you haven't created a Developer account yet, please do so at Remember that there is a fee of $99 a year to become an Apple Developer.


The Apple Developer account is only applied to users developing on Mac OS X. Make sure your version of Xcode is the same as or newer than the version of the OS on your phone. For example, if you have version 5.0 of the iPhone OS installed you will need Xcode that is bundled with the iOS SDK version 5.0 or later.

Time for action – obtaining the iOS developer certificate

Make sure that you're signed up for the developer program; you will need to use the Keychain Access tool located in /Applications/Utilities so you can create a certificate request. A valid certificate must sign all iOS applications before they can be run on an Apple device in order to do any kind of testing.

  1. Open Keychain Access | Certificate Assistant | Request a Certificate From a Certificate Authority.

  2. In the User Email Address field, type in the e-mail address you used when you registered as an iOS developer. For Common Name, enter your name or team name. Make sure that the name entered matches the information that was submitted when you registered as an iOS developer. The CA Email Address field does not need to be filled in so you can leave it blank. We are not e-mailing the certificate to a Certificate Authority (CA). Check Saved to disk and Let me specify key pair information. When you click Continue, you will be asked to choose a save location. Save your file at a destination where you can locate it easily such as your desktop.

  3. In the following window, make sure that 2048 bits is selected for the Key Size and RSA for the Algorithm, and then click Continue. This will generate the key and save it to the location you specified. Click Done in the next window.

  4. Next, go to the Apple Developer website:, click on iOS Dev Center, and log in to your developer account. Select the iOS Provisioning Portal tab and navigate to Certificates on the left-hand column. Click on the Development tab if it's not already selected and then select the Add Certificate button on the right side of the page.

  5. Click on the Choose File button, locate your certificate file that you saved to your desktop, and click on the Submit button.

  6. Upon pressing the Submit button, you will get an e-mail notification you specified in the Certificate Authority (CA) request form from Keychain Access. The person who created the certificate will receive this e-mail and can approve the request by pressing the Approve button. You can download the certificate once it has been approved.

  7. Click on the Download button and save the certificate to a location that is easy to find. Once this is completed, double-click on the file and you will see the following dialog:

  8. Click OK. This will install your iPhone Development Certificate in your Keychain.

What just happened?

We now have a valid certificate for iOS devices. The iOS Development Certificate is used for development purposes only and is valid for about a year. The key pair is made up of your public and private keys. The private key is what allows Xcode to sign iOS applications. Private keys are available only to the key-pair creator and are stored in the system keychain of the creator's machine. The following are other websites you can refer to to create valid certificates:

Adding iOS devices

You are allowed to assign up to 100 devices for development and testing purposes in the iPhone Developer program. To register a device, you will need the Unique Device Identification (UDID) number. You can find this in iTunes and Xcode.


To find out your device's UDID, connect your device to your Mac and open Xcode. In Xcode, navigate to the menu bar and select Window and click on Organizer. The 40 hex character string in the Identifier field is your device's UDID. Once the Organizer window is open, you should see the name of your device in the Devices list on the left. Click on it and select the identifier with your mouse, copying it to the clipboard:

Usually when you connect a device to the Organizer for the first time, you'll receive a button notification that says Use for Development. Select it and Xcode will do most of the provisioning work for your device in the iOS Provisioning Portal.


With your device connected, open iTunes and click on your device in the device list. Select the Summary tab. Click on the Serial Number label to show the Identifier field and the 40 character UDID. Press Command + C to copy the UDID to your clipboard.

Time for action – adding/registering your iOS device

To add a device to use for development/testing:

  1. Select Devices in the iOS Provisioning Portal and click on Add Devices.

  2. Create a name for your device in the Device Name field and put your UDID in the Device ID by pressing Command + V to paste the number you have saved on the clipboard.

  3. Click Submit when you are done.

Time for action – creating an App ID

Now that you have added a device to the portal, you will need to create an App ID. An App ID has a unique 10-character Bundle Seed ID prefix generated by Apple and a Bundle Identifier suffix that is created by the Team Admin in the Provisioning Portal. An App ID could look similar to the following example: To create a new App ID follow these steps:

  1. Click on the New App ID button in the App ID section of the portal.

  2. Fill out the Description field with the name of your application.

  3. You are already assigned a Bundle Seed ID (also known as Team ID).

  4. In the Bundle Identifier (App ID Suffix) field, specify a unique identifier for your app. It is up to you as to how you want to identify your app, but it is recommended that you use the reverse-domain style string, that is com.domainname.appname.


    You can create a wildcard character in the Bundle Identifier that you can share among a suite of applications using the same Keychain access. To do this, simply create a single App ID with an asterisk (*) at the end. You would place this in the field for the Bundle Identifier either by itself or at the end of your string: com.domainname.*. More information on this topic can be found in the App IDs section of the iOS Provisioning Portal:

What just happened?

All UDIDs are unique on every device and we can locate them in Xcode and iTunes. When we added a device in the iOS Provisioning Portal we took the UDID, which consists of 40 hex characters and made sure we created a device name so we can identify what we're using for development.

We now have an App ID for applications we want to install on a device. An App ID is a unique identifier that iOS uses to allow your application to connect to the Apple Push Notification service, share keychain data between applications, and communicate with external hardware accessories that you wish to pair your iOS application with.

Provisioning Profiles

A Provisioning Profile is a collection of digital entities that uniquely ties developers and devices to an authorized iOS development team and enables a device to be used for testing. These profiles tie your devices to your development team for testing and distribution.

Time for action – creating a Provisioning Profile

To create a Provisioning Profile, go to the Provisioning section of the iOS Provisioning Portal and click New Profile on the Development tab.

  1. Enter a name for the Provisioning Profile. It could be the same name as your application.

  2. Check the box next to Certificates.

  3. Select the App ID that you created for your application in the pull-down menu.

  4. Check the devices you wish to authorize for this profile.

  5. Click on the Submit button when you are done.

  6. You will be returned to the Development tab where the status will most likely say Pending. Click Refresh on your browser and it should show that your profile's status says Active.

  7. Click the Download button. While the file is downloading, launch Xcode if it's not already open and press Shift + Command + 2 on the keyboard to open Organizer.

  8. Under Library, select the Provisioning Profiles section. Drag the downloaded .mobileprovision file to the Organizer window. This will automatically copy the .mobileprovision file to the proper directory.

What just happened?

Devices that have permission within the Provisioning Profile can be used for testing as long as the certificates are included in the profile. One device can have multiple provisioning profiles installed.

Application icon

Currently our app has no icon image to display on the device. By default, if there is no icon image set for the application you will see a light gray box displayed along with your application name below it once the build has been loaded to your device. So launch your preferred creative developmental tool and let's create a simple image.

The application icon for iPhone/iTouch should be a 57 x 57 PNG image file or 72 x 72 for iPad. The image should always be saved as Icon.png and must be located in your current project folder. For iPhone / iPod touch devices that support Retina display, we need an additional high-resolution 114 x 114 icon named Icon@2x.png.

The contents of your current project folder will look like this:

Hello World/    name of your project folder
Icon.png         required for iPhone/iPod/iPad
Icon@2x.png       required for iPhone/iPod with Retina display

In order to distribute your app, the App Store requires a 512 x 512 pixel version of the icon. It is best to create your icon at a higher resolution first. Please refer to the Apple iOS Human Interface Guidelines for the latest official App Store requirements:

Creating an application icon is a visual representation of your application name. You will be able to view the icon on your device once you compile a build together. The icon is also the image that launches your application.

Creating the Hello World build for iOS

We are now set to build our Hello World application for our device. Since we have our provisioning profiles in place, the build process from here on is pretty simple. Make sure that you are connected to the Internet before creating a device build. You can build your application for testing in the Xcode Simulator or on a device.

Time for action – creating an iOS build

Follow these steps to creating a new iOS build in Corona SDK:

  1. Open the Corona Simulator and select Simulator.

  2. Navigate to your Hello World application and select your main.lua file.

  3. Once the application is launched on the simulator, go to the Corona Simulator menu bar and select File | Build | iOS or press Command + B on your keyboard. The following dialog box appears:

  4. Create a name for your app in the Application Name field. We can keep the same name Hello World. In the Version field, keep the number at 1.0. In order to test the app in the Xcode Simulator, select Xcode Simulator from the Build For drop-down menu. If you want to build for the device, choose Device to build an app bundle. Next, select the target device (iPhone or iPad) from the Supported Devices drop-down menu. Under the Code Signing Identity drop-down menu, choose the provisioning file you created for the specified devices you are building for. It is the same name as the Profile Name in the iOS Provisioning Portal on the Apple Developer website. In the Save to folder section, click Browse and choose where you would like your application to save in.

  5. If all the information has been confirmed in the dialog box, click on the Build button.


    It is more convenient to set your application to save on the Desktop; that way it is easy to find.

What just happened?

Congratulations! You now have created your first iOS application file that can be uploaded to your device. As you start developing apps for distribution, you will want to create new versions of your application so you can keep track of the changes in every new build you make. All the information from your Provisioning Profile was created in the iOS Provisioning Portal and applied to the build. Once Corona has finished compiling the build, the application should be located in your preferred folder you saved it under.

Time for action – loading an app on your iOS device

Select the Hello World build that you created and choose either of the following to load your app onto your iOS device. iTunes, Xcode, or the iPhone Configuration Utility can be used to transfer the application file.

If using iTunes, drag your build into your iTunes library and then synch your device normally.

Another way to install your app onto your device is to use Xcode since it provides a convenient method for installing iOS device applications.

  1. With the device connected, open Xcode's Organizer from the menu bar, Window | Organizer, and navigate to your connected device under the Devices list on the left.

  2. If a proper connection is established, you will see a green indicator. If it is yellow after a couple minutes, try powering the device off and on again or disconnect the device and connect it again. This will usually establish a proper connection.

  3. Simply drag your build file and drop it in the Applications area of the Organizer window and it will automatically install on your device.

    Lastly, you can use the iPhone Configuration Utility that is available as a separate download from the Apple website under the Support tab: It allows you to manage your configuration profiles, track and install provisioning profiles and authorized applications, and capture device information including console logs.

  4. Click on the Download button and follow the directions on how to install the program.

  5. Make sure that your device is connected to your computer, launch the iPhone Configuration Utility, and then click the Add button at the top left of the box. Navigate to your Hello World build on your desktop or wherever you saved it and then click Open.

  6. When your device is recognized, select your device under the Devices section. You will see a list of applications that are currently installed or yet to be installed. Click on the Install button next to your Hello World app you added to the utility.


    If you are testing the same version number of the same application repeatedly, make sure to delete the previous versions of your application from the device before a new install to remove any cached or associated data. Or use different version numbers in the build options.

What just happened?

We just learned three different ways using iTunes, Xcode, and the iPhone Configuration Utility to load an application build to an iOS device.

Using iTunes provides a simple drag-and-drop feature into your Library and then allows you to transfer the build as long as your device is synced up.

The Xcode method is probably the easiest and most common way to load a build to a device. As long as your device is connected properly and ready to use in the Organizer, drag-and-drop the build to Applications and it loads automatically.

Finally, the iPhone Configuration Utility is a step-by-step tool where you can easily differentiate which applications have been installed on your device. When you load your build within the main Library, the Devices area will pull up a list of applications you want to install or uninstall. After you locate your build, all you have to do is click the Install button and the file is loaded.

Testing our application on an Android device

Creating and testing our builds on an Android device does not require a developer account like how Apple does for iOS devices. The only tools you need to build for Android is a PC or Mac, Corona SDK, a JDK6 installation, and an Android device. If you plan on submitting an app to the Google Play Store, you'll need to sign up as an Google Play Developer at: There is a one-time $25 registration fee you have to pay if you want to publish software on the Google Play Store.

Creating the Hello World build for Android

Building our Hello World application is fairly simple since we do not have to create a unique Keystore or Key Alias for debug builds. When you're ready to submit an application to the Google Play Store, you'll need to create a release build and generate your own private key to sign your app. We'll discuss release builds and private keys in more detail later on in this book.

Time for action – creating an Android build

Follow these steps to create a new Android build in Corona SDK:

  1. Launch the Corona Simulator and select Simulator.

  2. Navigate to your Hello World application and select your main.lua file.

  3. Once your application is running on the simulator, go to the Corona Simulator menu bar and select File | Build For | Android (Windows)/Shift + Command + B on your keyboard (Mac). The following dialog box appears:

  4. Create a name for your app in the Application name field. We can keep the same name Hello World. In the Version Code field, set the number to 1 if that is not already the default number. This specific field must always be an integer and is not visible to users. In the Version Name field, keep the number at 1.0. This attribute is the string shown to users. In the Package field, you will need to specify a name that uses the traditional Java scheme, which is basically the reverse format of your domain name. For example, would work as a package name. The Project Path shows the location of where your project folder is. Target OS Compatibility currently supports Android 2.2 and newer devices running the ArmV7 processor. In the Keystore field, you will be signing your build with the Debug Keystore that is already provided in Corona. In the Key Alias field, select androiddebugkey from the pull-down menu if it's not selected. In the Save to folder section, click Browse and choose where you'd like your application to save in.

  5. If all the information has been confirmed in the dialog box, click on the Build button.


    For more information about Java package names, see the section on Unique Package Names in the Java documentation at:

What just happened?

You have created your very first Android build! See how simple that was? Since Corona SDK already provides the Debug Keystore and androiddebugkey Key Alias within the engine, most of the signing work is already done for you. The only requirement from you is to fill out the build information for your application and click on the Build button to make a debug build. Your Hello World application will save as an .apk file at the location you designated. The file name will appear as Hello World.apk.

Time for action – loading an app on your Android device

There are several ways to load your Hello World build to your Android device that don't require you to download the Android SDK. Here are some simple methods:

The most fundamental method to upload an .apk file onto your device is to transfer it to the SD Card via the USB interface. If your device doesn't come with some kind of file manager application, a great one you can download from the Google Play Store is ASTRO File Manager at: There are many other installers like AppInstaller at: AppInstaller allows you to install .apk files from your SD card. You can always do a normal search for the preceding apps on the Google Play Store app on your device.

  1. Under your device's Settings, select Applications and then select Development. Tap on USB Debugging if the mode is not active.

  2. Go back a couple of screens to the Applications section. Enable Unknown Sources if it is not already active. This will allow you to install any non-market application (that is, debug builds). Select the home button on your device when done.

  3. Connect the device to your computer with a USB cable. You will see a new notification that a new drive has connected to your PC or Mac. Access the SD drive and create a new folder. Name the folder something that you can identify easily for your Android builds. Drag-and-drop your Hello World.apk file from the desktop to the folder.

  4. Eject the drive from your desktop and disconnect your device from the USB cable. Launch ASTRO File Manager or AppInstaller, whichever app you decided to download from the Google Play Store. In ASTRO, select File Manager, search for the folder you added on your SD card and select it. In AppInstaller, search for your newly named folder and select it. In both apps, you will see your Hello World.apk file. Select the file and a prompt will appear asking you to install it. Select the Install button and you should see your Hello World application appear in the Apps folder of your device.

    A convenient method is through Dropbox. You can create an account at: Dropbox is a free service that lets you upload/download your files on your PC/Mac and mobile devices.

  5. Download the Dropbox installer and install it on your computer. Also, download the mobile app from the Google Play Store (which is also free) on to your device and install it.

  6. Log in to your Dropbox account on your computer and mobile device. From your computer, upload your Hello World.apk file.

  7. Once it has finished uploading, go to the Dropbox app on your device and select your Hello World.apk file. You will be greeted with a screen that will ask you if you want to install the application. Select the Install button. Assuming that it installs correctly, another screen will appear saying Application installed and you can launch your Hello World app by pressing the Open button that is available.

    One of the easiest methods is through Gmail. If you don't already have a Gmail account, create one at:

  8. Log in to your account, compose a new e-mail and attach your Hello World.apk file to the message.

  9. Address the recipient of the message to your own e-mail address and send it.

  10. On your Android device, make sure you have your e-mail account linked on there as well. As soon as you receive the message, open the e-mail, and you will be given the option to install the application to your device. There will be an Install button or something similar displayed.

What just happened?

We just learned several ways on how to load a .apk file to an Android device. The preceding methods are some of the easiest ways to load an application quickly without running into any problems.

Using the file manager method allows you to access your .apk files easily without requiring any carrier data or Wi-Fi connection. By using a USB cable that is compatible with your device and connecting it to your computer, it's a simple drag-and-drop procedure.

The Dropbox method is the most convenient method of... once you have it set up on your computer and your mobile devices. All you have to do is drag-and-drop your .apk file to your account folder and it's instantly accessible to any device with the Dropbox app installed. You can also share your files through a download link—another great feature provided by Dropbox.

Setting up a Gmail account and sending your .apk files as attachments to yourself is a simple process if you don't want to download any file managers and other programs to your device and computer. The only thing you have to remember is that you can't e-mail an attachment over the size of 25 MB in Gmail.

Pop quiz – understanding Corona

  1. When using Corona, which of the following statements is true?

    a. You need a main.lua file to launch your application.

    b. Corona SDK only runs on Mac OSX.

    c. The Corona Terminal doesn't launch the simulator.

    d. None of the above.

  2. How many iOS devices can you use for development in the iPhone Developer Program?

    a. 50.

    b. 75.

    c. 5.

    d. 100.

  3. What does the Version Code have to be when building for Android in Corona SDK?

    a. A string.

    b. An integer.

    c. Has to follow the Java scheme format.

    d. None of the above.


In this chapter, we covered some of the necessary tools needed to start developing applications for Corona SDK. Whether you are working on a Mac OS X or Microsoft Windows, you will notice the similarities on how to work on both operating systems and how simple it is to run Corona SDK.

To familiarize yourself with Corona better, try doing the following:

  • Take the time to look into the sample code provided by Corona to view the capabilities of the SDK

  • Feel free to alter any of the sample code to your liking to get a better understanding of programming in Lua

  • Whether you're working on iOS (if you're a registered Apple Developer) or Android, try installing any of the sample code to your device to see how the applications work outside the simulator environment

  • Take a look at the Ansca forums at and browse through the latest discussions on Corona development by fellow Corona SDK developers and personnel

Now that you understand the process of displaying objects in Corona, we'll be able to dive into other functions that will help create an operational mobile game.

In the next chapter, we'll be going into more depth on Lua programming language and learning simple coding techniques that are similar to the sample code in Corona. You will get a better understanding of the Lua syntax and notice how fast and easy it is to learn compared to other programming languages. So let's get started!

Left arrow icon Right arrow icon

Key benefits

  • Build once and deploy your games to both iOS and Android
  • Create commercially successful games by applying several monetization techniques and tools
  • Create three fun games and integrate them with social networks such as Twitter and Facebook


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.

What you will learn

Optimize your game for mobile using touch and accelerometer Add sound and music to your game Master game physics such as collision detection Add achievements and leaderboards with OpenFeint and Game Center Monetize your game with in app purchase and advertising. Make your game socially aware by sharing messages and scores on Facebook and Twitter.

Product Details

Country selected

Publication date : Apr 24, 2012
Length 408 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781849691888
Category :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details

Publication date : Apr 24, 2012
Length 408 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781849691888
Category :

Table of Contents

18 Chapters
Corona SDK Mobile Game Development Beginner's Guide Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon
About the Reviewers Chevron down icon Chevron up icon Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
1. Getting Started With Corona SDK Chevron down icon Chevron up icon
2. Lua Crash Course and the Corona Framework Chevron down icon Chevron up icon
3. Building our First Game: Breakout Chevron down icon Chevron up icon
4. Game Controls Chevron down icon Chevron up icon
5. Animating our Game Chevron down icon Chevron up icon
6. Playing Sounds and Music Chevron down icon Chevron up icon
7. Physics: Falling Objects Chevron down icon Chevron up icon
8. Operation Storyboard Chevron down icon Chevron up icon
9. Handling Multiple Devices and Networking your Apps Chevron down icon Chevron up icon
10. Optimizing, Testing, and Shipping your Games Chevron down icon Chevron up icon
11. Implementing In-App Purchases Chevron down icon Chevron up icon
Pop Quiz Answers Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by

No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial


How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to
  • To contact us directly if a problem is not resolved, use
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.