Android Game Development with Corona: Getting Started

Posted by Dr. Burton on June 19, 2010 in Android, Corona, Mobile |

Android Game Development with Corona: Getting Started

An Apple MacIntosh to code on and
Corona SDK v2.0 (or newer) (http://www.anscamobile.com/).  You do not need to download the following unless you are planning to do non-Corona app development for Android based systems:
Android SDK (http://developer.android.com/sdk/index.html)
Java JDK (http://java.sun.com/javase/downloads/index.jsp)

Wirefly: DROID X by Motorola Coming July 15th

You don’t have to own any of this (well, except for the Mac), you can easily get started with the 30 day trial version of Corona SDK and the trial version of the Android SDK.

Hello World
Ready to do your first program? Typically this is done as “Hello World”.
Open your editor of choice (I’m using BBEdit in my demonstration).
Create a folder (or project) and then a file named ‘main.lua’ (after creating a project, click File > New > and select Other)
Type:
print (“Hello World”)

and save your file.

Now, open the Corona Terminal (make sure it is the terminal, not the simulator, or you won’t see your program run).
In the dialog box, go to your FOLDER that contains the main.lua file and click ‘open’.
You will see the Android simulator.. ignore it for right now. Everything happens in the terminal for this first app.
In your terminal window, you should see your “Hello World”. Congratulations! You’ve made your first Corona on the iPhone app!

Not impressed? That’s because the print function that we used to display “Hello World” is used to display information to a log file or terminal.
Okay, let’s make something happen on the simulator!

Back in BBEdit (you can use the same file),
Type:
Local textobj = display.newText(“Hello World”, 50, 50, nil, 24)
Textobj:setTextColor(255, 255, 255)

What did you just do? Here’s the run down:
First we created a local variable called textobj. We set textobj = to the object that we create by calling display.newText, passing it the text (“Hello World”), the X & Y location of the top left corner of the text, nil (a parameter reserved for future use), and 24 (the size of the text to be created).
Second, we set the color of the textobj that was just created using the R, G, B color system (each color (red, green, blue) having a value between 0 – 255). We set the color to white.
By default, the text object has no color, so you have to assign it a color for it to be seen. You COULD create text (and you might want to in a future app) that has no color, but for now, it doesn’t serve any purpose.
Try the app out!
Now you have made your first REAL Corona app!

Android Game Development with Corona: Hello World
Runtime
7:40
View count
20,104

Tags: , , , ,

7 Comments

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree

Copyright © 2010-2012 Burtons Media Group All rights reserved.
Desk Mess Mirrored version 1.9.1 theme from BuyNowShop.com.