You are on page 1of 13

App Development Tool | Corona in 5 minutes

10/2/13 11:03 PM

Forums

Download

Sign-in

Products

Community

Resources

Pricing

Blog

About

Search

A new build of Corona SDK is now available to subscribers. Not a subscriber? Subscribe now. CoronaSDK 2013.1225 | Released: 2 Oct 2013, 11:05am | What's New | Download Now

Corona in 5 minutes
Let's start with a quick introduction to Corona SDK. We'll focus just on the essentials without getting stuck in the details. We want to get you coding and creating cool, useful, and engaging apps quickly and easily. We'll talk about some basics like variables and functions as well as incorporate animation and interactivity so you get a sense of what's possible. Keep in mind this is just an introductory lesson, so you won't find a complete explanation of any one feature. Our aim is to address multiple audiences. Experienced programmers should be able to extrapolate the information in this chapter for their own needs. Beginners can use this as a springboard for writing their own small, simple apps.

Getting Started with Corona Corona in 5 minutes


Download Tutorial Files Hello World Simulator vs Terminal Hello World on the Simulator Rapid Prototyping Basic Interactivity Animation and Sound You're All Set

Download Tutorial Files


The files for this tutorial are available for download. HelloWorldTutorial.zip

Quick Start Guide Troubleshooting Working with Corona Basic Functions Images, Shapes, and Text Animation and Motion Audio, Video, and Photos Data and Files Networking and Web Services System and OS Interactivity and Detecting Events Physics Engine Native UI Advanced Programming Techniques Roadmap Then save it to a file called main.lua in some folder that's easy Corona folder to locate. Generally, every program should have its own folder on your system. To run the program, you need to launch the Corona Simulator. All Corona SDK files should be in the Corona folder in your Applications folder (see Getting Started Guide for more information on how to install the Corona SDK.) The contents of the SDK will look something like the picture at right. Double-click on the icon for Corona Terminal (the circled icon below). This will launch a Terminal window and bring up a file dialog. In the dialog, navigate to the folder containing your main.lua file and click the Open button. At this point, you will see Hello World in the Terminal window:
print( "Hello World" )

Hello World
The best way to learn how to use Corona SDK is by writing an app. To do this, we write programs in a language called Lua. In keeping with tradition, let's write a some Lua code that prints "Hello World." The big roadblock is figuring out the details of how to actually use Corona SDK to do this. Once you've got these details mastered, everything gets a lot easier. Let's get started! What you'll need is a text editor to write your program in. Later, you'll save that file to a folder so that the Corona Simulator can run and show you the results. In the text editor, type the following:

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 1 of 13

App Development Tool | Corona in 5 minutes

10/2/13 11:03 PM

You will also see a blank simulator window (right) that simulates what would display on the actual phone. In this case, the phone screen remains blank because we're told the program to output to the Terminal. Let's explain how this program worked. The app launches from the file called main.lua . The simulator loads this file and follows the instructions contained inside. Generally, an app consists of statements and variables. Statements provide instructions on what operations and computations need to be done; variables store the values of these computations. In this program, we use a function called print . A function is just a collection of statements that perform some task. You send inputs into the function called parameters (or arguments). Some functions return results. In the case of print , all it does is output the arguments as strings to the Terminal.

Simulator vs Terminal
So why did Hello World only display in the Terminal window and not in the simulator? That's because print is designed to output messages to the Terminal. Its purpose is to output you to send diagnostic messages about what's happening in your program. And in general, the Terminal window gives you the ability to see warning/error messages that the simulator generates or print your own messages.

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 2 of 13

App Development Tool | Corona in 5 minutes

10/2/13 11:03 PM

Hello World on the Simulator


To get things displaying on the simulator screen, we need to use different functions that come from Corona's graphics library. A library is a collection of functions that provides useful, but related functionality. To show Hello World in the simulator, you need to add the following two lines:

local textObject = display.newText( "Hello World!", 50, 50, nil, 24 ) textObject:setTextColor( 255,255,255 )

Let's explain what's happening. newText is a function of the display library that returns an object that will represent the text on the screen. Library functions deserve some more explanation. In this example, you can think of newText as belonging to the display library. This relationship is known as a property relationship. So to access the newText property of display , you have to use a dot. Hence, you write display.newText but not newText by itself. The function setTextColor is a special method called an object method. It uses a special colon syntax that means it is related to the text object you created. Typically these methods modify the variable before the colon (i.e. textObject ). In this case, the text object has no color by default, so we need to assign the Red, Green, and Blue color channels. These numbers range from 0-255. So for white, we need 255 for each channel.

Rapid Prototyping
One of the most powerful things about the Corona SDK is the ability to make quick changes and see those changes instantly. Let's revisit our previous example to see how this works. You can also start with the HelloWorld project in the Sample Code. Launch the simulator, navigate to the folder for your program, and click open as you did before. Now, open up the main.lua file in your text editor and try changing the 3 arguments to setTextColor . For example, you might have done something like:

local textObject = display.newText( "Hello World!", 50, 50, nil, 24 ) textObject:setTextColor( 255, 0, 0 )

Now, save the file and then go back to the simulator. Under the File menu, click the Relaunch submenu item (File > Relaunch) or use the keyboard shortcut R (command-R) in the simulator. This reloads your main.lua file without having to restart the simulator. Notice how the color of the text changes immediately. In the version above, the text would appear red. As you develop your application, you'll find yourself doing this sort of thing very often. You'll load your app in the simulator, make some edits to your main.lua file in text editor, switch back to the simulator and relaunch your code to see the results. This makes it really easy to make edits and see the results, all while avoiding the time and trouble of quitting and restarting the simulator.

Basic Interactivity
Let's add some interactivity by creating a button that will change the color of the text randomly. Starting with your HelloWorld project, add the following lines at the end of main.lua to load an image:

local button = display.newImage( "button.png" ) button.x = display.contentWidth / 2 button.y = display.contentHeight - 50

This loads an image called button.png and positions it at the bottom center of the screen. It uses another display library function ( display.newImage ). This function returns an image object that we store in the variable button . We could have called the variable anything, but the name button seemed natural since we are going to turn this image into a button. The image object that we created has built-in properties that we can modify. These include the x,y positions on the screen which refer to the position of the center of the image relative to the top-left corner of the screen. To get a position towards the bottom of the screen, we took advantage of the display properties of the screen display.contentWidth and display.contentHeight to help us center the position of the image.

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 3 of 13

App Development Tool | Corona in 5 minutes

10/2/13 11:03 PM

To turn the image into an actual button, we need to make it respond to events. There are various kinds of events. For this example, we will make the image respond to tap events (which are similar to single mouse clicks on a desktop computer). When you add the following lines at the end of main.lua , you can click on the image and the text color changes.

function button:tap( event ) local r = math.random( 0, 255 ) local g = math.random( 0, 255 ) local b = math.random( 0, 255 ) textObject:setTextColor( r, g, b ) end button:addEventListener( "tap", button )

Let's see how this works. The code above has two parts. The first part defines an object listener for the image object button . An object listener (usually called a table listener) is an object method whose name matches the name of the event. Object listeners are just another name for object methods where a specific convention is followed: the name of the method is the same as the name of the event we are interested in, so in this case, we call the method tap . The colon is present because that's the syntax for defining object methods. The second part is where we register this object listener to receive tap events. Fortunately, the image object button (like all objects created by the display library) has a built-in object method called addEventListener that allows us to make it interactive. Because it's an object method, the image object variable button is to the left of the colon and the object method addEventListener is to the right. The first argument is the name of the event and the second argument is the image object itself. When the user taps on the image, the system sees that an object listener has been registered. It looks for an object method named tap inside that object and then calls that method. In our implementation of the tap object method, we generate 3 random numbers between 0 and 255 and use those to set the new text color. The final code for this is available in the HelloWorld2 folder.

Animation and Sound


Let's animate the text and add some sound every time the user taps the button. Start with the HelloWorld2 project and add the following lines at the end of main.lua so that the text will move vertically down by 100 pixels:

transition.to( textObject, { time=1000, y=textObject.y+100 } )

Here, we are using the transition library which does a lot of the heavy lifting on our behalf (see Animation). We can add some sound by adding one line to the tap object method:

function button:tap( event ) local r = math.random( 0, 255 ) local g = math.random( 0, 255 ) local b = math.random( 0, 255 ) textObject:setTextColor( r, g, b ) media.playEventSound( "beep.caf" ) end button:addEventListener( "tap", button )

Here we are using the media library which provides multimedia support.

You're All Set


So thats it for the quick tour of Corona. There's plenty more to explore like using the accelerometer to create novel user interactions, getting GPS information to enable location-based functionality, storing data in a database, and much much more. Hopefully, you've gotten a taste for how easy Corona makes it to create cool apps and games. If you want to learn more, head over to our Overview page. Or, if youd really like to dig into a book, check the book list for titles available for sale online or at your local bookseller.

Getting Started with Corona

up

Quick Start Guide

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 4 of 13

App Development Tool | Corona in 5 minutes

10/2/13 11:03 PM

Replies

Viewing options
Threaded list - expanded Save settings
Select your preferred way to display the comments and click "Save settings" to activate your changes.

Date - oldest first

50 comments per page

Posted on Mon, 2010-08-09 06:20

#1

Philippe Chapuy
Offline
Test Driver
Joined: 9 Aug 2010

Pretty cool, i want to learn more after reading this...

Posted on Wed, 2010-08-18 06:56

#2

dario
Offline
Test Driver
Joined: 18 Aug 2010

Thank you guys. I am euphoric ;) Want to learn more.

Posted on Sat, 2010-10-23 06:49

#3

wizball
Offline
Test Driver
Joined: 20 Oct 2010

remove the :tap from the function, and change the event type to "touch" when adding the event listener. For some reason I kept getting addEventListener as nil and when I did this it worked.

Posted on Sat, 2010-11-06 18:33

#4

DavidBFox
Offline
Pro Developer
Joined: 10 Oct 2010

Works fine for me as is, wizball... if you replace "tap" with "touch" you'll get two events... one when you touch the screen, and one when you release (so you'll hear two beeps and get two color changes for each screen touch). You'd have to then check the event.phase to see if it's equal to "began" (beginning of touch) or "ended" (release of the touch).

Posted on Sat, 2010-12-18 17:27

#5

magnp01
Offline
Test Driver
Joined: 29 Nov 2010

This tutorial makes it clear to me that I can learn "lua"

Posted on Thu, 2010-12-23 15:29

#6

Antheor
Offline
Test Driver
Joined: 22 Sep 2010

I have the message following runtime error : "please check console output for detail". WHen opening /utilities/console, I have no corona message at the moment the error occured (but some from the day before). Am I checking the right console ??? BTW, I got the error trying to do something as simple as trying to catch a tap on screen (not on a button, just on screen) (launching a function)... could you help me to get the single line code -I suppose- for this tremendously hard task :))

Posted on Mon, 2011-01-17 18:52

#7

Gilbert

Hi @Antheor,

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 5 of 13

App Development Tool | Corona in 5 minutes


Offline
Alumni
Joined: 5 Apr 2010

10/2/13 11:03 PM
To open the console that the message is referring to you have to use "Corona Terminal". First, close the simulator if you have it open now. Then go to the folder where you have the "Corona Simulator" (which should be in the Corona folder in your Applications folder) and you'll see "Corona Terminal" in there. Double click "Corona Terminal" and you'll see the Terminal window come up. This will then trigger the simulator. From here on you can open apps as you normally would in the simulator, but keep the terminal where you can see it. Regarding detecting taps anywhere on the screen, there are two ways to do that. You could create a large black rectangle, the full width and height of the screen, then detect tap events on that. It's basically like a big button. You could also do it by detecting runtime events. Try this code: (Make sure you have Corona Terminal open. You should see a message in the terminal each time you tap the simulator: "tap detected".)

1 2 3 4 5 6 7 8 9 10 11 12 13

local textObject = display.newText( "Hello World!", 50, 50, nil, 24 ) textObject:setTextColor( 255, 0, 0 ) function tapListener( event ) local r = math.random( 0, 255 ) local g = math.random( 0, 255 ) local b = math.random( 0, 255 ) textObject:setTextColor( r, g, b ) print('tap detected') end Runtime:addEventListener( "tap", tapListener )

Posted on Mon, 2011-01-17 18:18

#8

Danieljh75
Offline
Test Driver
Joined: 17 Jan 2011

What's changed? The text works in the simulator up to the point where it turns red. Appending the main.lua file with the code for a button didn't work. I read the comment regarding the beta and a different version. I tried the code with the display.stageHeight and also the display.contentHeight. No difference. I copied and pasted just to be sure I wasn't making a typo. No go. So if the everyone else is / was successful, what did I miss?

Posted on Mon, 2011-01-17 18:40

#9

Gilbert
Offline
Alumni
Joined: 5 Apr 2010

Hi @Danieljh75, The button in this example requires an image named "button.png" to be in the same folder as the main.lua file. Without the image, you won't see a button. To try this example without using an image, you could draw a rounded rectangle on the screen and make that tappable. Try this code: (Notice on line 4 that a rounded rectangle is created and named "button".)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

local textObject = display.newText( "Hello World!", 50, 50, nil, 24 ) textObject:setTextColor( 255, 0, 0 ) local button = display.newRoundedRect(0, 0, 290, 75, 12) button:setFillColor(0, 255, 0) button.x = display.contentWidth / 2 button.y = display.contentHeight - 50 function button:tap( event ) local r = math.random( 0, 255 ) local g = math.random( 0, 255 ) local b = math.random( 0, 255 ) textObject:setTextColor( r, g, b ) end button:addEventListener( "tap", button )

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 6 of 13

App Development Tool | Corona in 5 minutes

10/2/13 11:03 PM
#10

Posted on Mon, 2011-01-17 19:11

Danieljh75
Offline
Test Driver
Joined: 17 Jan 2011

I couldn't see the color blue where it said to get the tutorials. Someone had to show me that it was there. But I see that it has been modified. Thanks and thank you for the quick response.

Posted on Mon, 2011-01-17 19:15

#11

Gilbert
Offline
Alumni
Joined: 5 Apr 2010

I just added that blue box to try to highlight the tutorial files available for download. I can understand how they were easily missed. Hopefully this helps other people as well. And here's a direct link to the download: http://developer.anscamobile.com/sites/default/files/HelloWorldTutorial.zip

Posted on Tue, 2011-01-18 13:11

#12

Anchor45
Offline
Test Driver
Joined: 18 Jan 2011

I am unable to select the Corona Terminal on my mac. The icon is dim and I get the error message "Please select a main.lua file or a directory that contains that file." What did I do wrong!? or, what am I doing wrong?

Posted on Tue, 2011-01-18 15:23

#13

Danieljh75
Offline
Test Driver
Joined: 17 Jan 2011

Let me help you with text edit first (trust me on this one) then help you with CoronaSimulator.app. -On your mac, go to applications and open TextEdit. -Go to TextEdit's preferences. -Change the document format from 'Rich Text' to 'plain text.' It may assist you in the future. Then just close the preferences window. -On the text edit app, close the first blank text window that appeared. Go to file menu and select new. The window will look very plain and bland. This is good. -On the first line, type print("Hello World!") -Select file menu and 'save as.' -Save the file as "main.lua" and save it somewhere like your desktop for this example. Corona: Navigate to your applications folder and open the Corona directory. From here, you'll want to open the CoronaSimulator.app. Ignore the terminal or anything else that appears. With the CoronaSimulator.app still selected as the application that you're using, click on the file menu and select open. Navigate to the "main.lua" that you saved on your desktop. Now, the little terminal window will display a line of text that says, "Hello World!", although, without the quotations being displayed. After this, read along the tutorial and use the demo files that are linked at the top of the page. I'm sure a moderator will assist you if you need more in-depth guidance. Dan

Posted on Tue, 2011-01-18 21:03

#14

naytronic5000
Offline
Test Driver
Joined: 18 Jan 2011

How do you code for a difference in touching and releasing similar to onclick and release kind of actions?

Posted on Wed, 2011-01-19 10:51

#15

Gilbert
Offline

Hey @naytronic5000,

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 7 of 13

App Development Tool | Corona in 5 minutes

10/2/13 11:03 PM
You can do this by checking the phase property of the touch event. There are five phases for a touch: "begin", "moved", "ended", "stationary" and "cancelled". Generally, the first three are all you need. Here's an example of a touch listener that will do things based on the touch phases:

Alumni
Joined: 5 Apr 2010

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

function myButtonListener(event) local phase = event.phase if phase =="begin" then print('touch started!') else if phase == "moved" then print('the user is moving the touch now') else if phase == "ended" then print('the touch ended') end end

Take a look at some of the articles in this section: http://developer.anscamobile.com/content/application-programming-guide-eventhandling Also, take a look at this sample app: http://developer.anscamobile.com/sample-code/transition The startDrag function in this sample app uses the different event phases and also uses setFocus() to maintain the touch even if the user passes over another object that has a touch listener. You don't want other touch listeners interfering while your user still has his or her finger on the screen.

Posted on Wed, 2011-01-19 01:04

#16

Antheor
Offline
Test Driver
Joined: 22 Sep 2010

Thx for the answer Gilbert.

Posted on Thu, 2011-01-20 12:23

#17

timecmdr
Offline
Test Driver
Joined: 19 Jan 2011

Cool I love this stuff Man!

Posted on Thu, 2011-01-20 17:19

#18

naytronic5000
Offline
Test Driver
Joined: 18 Jan 2011

@Gilbert I'm a uber newb! I guess i'm just not grasping it! I read the articles and they all deal with ui.lea files? It just doesn't make since to me!

Posted on Sat, 2011-01-22 15:25

#19

jvega
Offline
Test Driver
Joined: 22 Jan 2011

Great tutorial! I have some previous C++ and iPhone SDK background and I'm already finding Lua to be much easier. Can't wait to dig deeper!

Posted on Sat, 2011-01-29 03:36

#20

Paul Williamson
Offline

Newbie here, top stuff but ran into a minor glitch. Got the "Hello World" up and changed the text color but when I tried to add the button got an

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 8 of 13

App Development Tool | Corona in 5 minutes


error.. WARNING:Failed to find image(button.png) How can I point the simulator in the right direction to find the .png file? thanx

10/2/13 11:03 PM

Test Driver
Joined: 28 Jan 2011

Posted on Sat, 2011-01-29 04:20

#21

jvega
Offline
Test Driver
Joined: 22 Jan 2011

Fellow newbie here, Paul. Ran into the same problem. There is probably a way to direct Corona via an explicit path to the file but the easies thing to do is run a search for the button.png (which is buried in your Corona example files somewhere) and simply copy and paste it into the same folder that contains your "Hello World" main.lua file. The code as it's written expects the image file to be located in the same file as the main. Hope that helps!

Posted on Sat, 2011-01-29 08:45

#22

tdbriscoe
Offline
Test Driver
Joined: 27 Jan 2011

I've worked through this demo on the Windows beta. It worked fine except for playing the sound file. I switched the ".caf" file for a ".wav" and it worked.

Posted on Sat, 2011-01-29 20:19

#23

Paul Williamson
Offline
Test Driver
Joined: 28 Jan 2011

Great, thanx..

Posted on Wed, 2011-02-02 22:22

#24

LTG
Offline
Test Driver
Joined: 31 Jan 2011

Very good information. Thanks!

Posted on Wed, 2011-02-02 22:49

#25

LTG
Offline
Test Driver
Joined: 31 Jan 2011

@ naytronic5000 they are .lua files and if your using mac try textwrangler. If your using pc, try something like Notepad++ @Paul Williamson and jvega See Post #9 Hope that helps : )

Posted on Thu, 2011-02-03 19:58

#26

Hammoud
Offline
Test Driver
Joined: 3 Feb 2011

Can this work on a PC? Textwrangler didnt work so i downloaded notepad+++ like some of you mentioned. Im not understanding how to get it as a main.lua file? If someone can please help i will be very thankful.

Posted on Sun, 2011-02-06 14:11

#27

troynall
Offline
Test Driver
Joined: 8 Nov 2010

when saving the "main.lua" from your editor make sure you dont include the default .txt extension. Some editors by default add the .txt extension to your files. I put "main.lua" in the filename box and then select file type as "txt" but do not save it with a txt extension. There should be a box that remembers your preferences.

Posted on Tue, 2011-02-08 15:24

#28

RGgamer

I am trying to display pictures from my files but can't. can you help me?

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 9 of 13

App Development Tool | Corona in 5 minutes


p.s. I am a windows user

10/2/13 11:03 PM

Offline
Test Driver
Joined: 17 Jan 2011

Posted on Tue, 2011-02-08 15:30

#29

RGgamer
Offline
Test Driver
Joined: 17 Jan 2011

same problem

Posted on Tue, 2011-02-08 15:38

#30

RGgamer
Offline
Test Driver
Joined: 17 Jan 2011

thanks alot jvega!!!!!! really helped!!

Posted on Sun, 2011-02-13 13:47

#31

elizabeth
Offline
Test Driver
Joined: 14 Jan 2011

Okay just did my first hello world test. I always knew a tool like Corona would come along but OMG things move fast in Mobile development!!! @ElizabethBoylan

Posted on Sat, 2011-02-19 21:53

#32

MacMusings
Offline
Test Driver
Joined: 22 Jan 2011

Hey guys I have a separate .caf file that is stored in the same folder as my main.lua file but fo some reason that .caf file is not playing. Can you help me out!!!

Posted on Sat, 2011-02-19 22:32

#33

troynall
Offline
Test Driver
Joined: 8 Nov 2010

1) double check your .caf file name. 2) make sure extension to cat file in not capitalized. also try posting you code. its probably a very small mistake like missing a double quote. also try quitting the simulator completely. and then restarting again just for good measure.

Posted on Sun, 2011-02-20 00:14

#34

DavidBFox
Offline
Pro Developer
Joined: 10 Oct 2010

MacMusings, right, to double-check the file name, click on the file and hit command-I (if you're on a Mac) and make sure the file extension isn't hidden. I've seen files that look ok in the finder, but then find there's actually another hidden extension (so maybe sound.caf.aif for example, with the .aif portion hidden).

Posted on Mon, 2011-02-28 08:46

#35

alarcine
Offline
Test Driver
Joined: 16 Jan 2011

Where could I find information for the Corona library functions?. The tutorials delve into just a few of them. I cannot find any compete listing and explanation of the functions available...

Posted on Mon, 2011-02-28 10:06

#36

troynall
Offline
Test Driver

@alarcine http://developer.anscamobile.com/reference

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 10 of 13

App Development Tool | Corona in 5 minutes


Joined: 8 Nov 2010

10/2/13 11:03 PM

Posted on Mon, 2011-03-07 14:58

#37

kites
Offline
Test Driver
Joined: 16 Jan 2011

Sorry for the noob question but, every time I try to launch the code it says unexpected symbol near '{'.

Posted on Mon, 2011-03-07 19:21

#38

kites
Offline
Test Driver
Joined: 16 Jan 2011

Now the sound won't play when i click on the button i have gotten every thing else down except for the sound

Posted on Wed, 2011-03-16 22:48

#39

qianlima210210
Offline
Test Driver
Joined: 26 Jan 2011

why the cat file can not play?

Posted on Thu, 2011-10-13 02:46

#40

class0402
Offline
Test Driver
Joined: 13 Oct 2011

About the Caf sound not playing. The HelloWorld tutorial unzips into three folders. There is no beep.caf in the first one. If you start by launching main.lua in the first one, it doesn't see a beep.caf sound file. It's in the HelloWorld2 folder. So the main.lua file in the HelloWorld folder seems to only see the resources in that folder, an important fact not mentioned in the tutorial. Also, the tip on setting text editor preferences is great, after half hour of frustration on a 5 minute tutorial... note to tech writers...

Posted on Sun, 2011-03-27 21:22

#41

terasaki
Offline
Test Driver
Joined: 27 Mar 2011

I can't play sound too. So beep.caf file is broken? I get other caf file(aiff) and replace beep.caf. I can play sound.

Posted on Wed, 2011-04-13 20:30

#42

binyu1749
Offline
Test Driver
Joined: 13 Mar 2011

What? 1 function button:tap( event ) 2 local r = math.random( 0, 255 ) 3 local g = math.random( 0, 255 ) 4 local b = math.random( 0, 255 ) 5 textObject:setTextColor( r, g, b ) 6 end 7 8 button:addEventListener( "tap", button ) This representative is assorted the meaning?

Posted on Tue, 2011-04-26 11:02

#43

rwgeorge
Offline
Test Driver
Joined: 22 Apr 2011

Holy cow people...change Beep.caf to Beep.wav and it will work. Now, was that hard?

Posted on Tue, 2011-06-28 10:56

#44

Cisco Antonio

The .caf file is short for Core Audio Format sound file for Mac based computers. Make sure your image and sound targets that you refer to in your code are spelled the same way for the

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 11 of 13

App Development Tool | Corona in 5 minutes


Offline
Test Driver
Joined: 3 Nov 2010

10/2/13 11:03 PM
files they refer to. If you are using a Windows PC, use a .wav or .mp3 file in the same folder as your main.lua file it should work properly.

Posted on Tue, 2011-08-30 16:23

#45

perseusspartacus
Offline
Test Driver
Joined: 9 Aug 2011

In the 'Bridge' sample code, the background picture is created with this code: local background = display.newImage( "jungle_bkg.png", 0, 0, true ) I know what the 'true' parameter is (it explains it just above this code in the file). What I want to know is what those '0's are. Are they x and y coordinates for the top left corner of the picture?

Posted on Sun, 2011-09-11 17:20

#46

natecope
Offline
Test Driver
Joined: 11 Sep 2011

How can I start the console on a PC? I do not see the console executable.

Posted on Tue, 2011-09-13 12:43

#47

stevenljackson1
Offline
Test Driver
Joined: 13 Sep 2011

I was able to start CoronaSimulator.exe and the console popped up as well as the simulator. I saw both "Hello World!" messages, one in each window. Hope this helps.

Posted on Mon, 2011-10-31 05:52

#48

underwaterdiver
Offline
Test Driver
Joined: 28 Oct 2011

Wow, this is the stuff. I've been a newbie for two months and reading all the iPhone material I could get and doing the chapters and exercises getting lost on where to put certain snippets of code. Corona SDK is the bomb. Make that Bomb with a capital B!!! I'm going from trial today straight to the PRO. Why wouldn't I??? It just makes sense to publish to all the markets with the same app. Thanks ANSCAMOBILE!!! Richard

Posted on Mon, 2011-12-05 07:06

#49

BareJonas
Offline
Test Driver
Joined: 18 Nov 2010

When I change the "View As" form iPhone to iPhone4 for the image button and text gets rezized to half the original size (or something) How come? How do I fix this?

Posted on Sun, 2012-01-01 16:54

#50

newbie2013
Offline
Test Driver
Joined: 31 Dec 2011

Love the relative simplicity of the Corona interface/Lua programming language. However, the example here may be somewhat confusing for a beginner who is typing the program him/herself, who may not know that the command "display.newImage" requires a graphics file "button.png" to be present in the same folder, or that the command "media.playEventSound" requires a sound file "beep.caf" to be present in the same folder. Additionally, "beep.caf" does not work in Windows, so will need to be substituted with a different sound file. Still, I look forward to programming in Corona!

next

last

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 12 of 13

App Development Tool | Corona in 5 minutes

10/2/13 11:03 PM

Products Corona SDK Enterprise Support & Training

Community Forum Meetups and Events Hall of Fame Corona Ambassadors Certified Developers

Resources Documentation 3rd Party Tools Case Studies FAQs

Get Corona Starter: Publish Free Buy Pro

About Jobs Press Contact

Social

Copyright 2009-2013 Corona Labs Inc. A mobile development software company. All rights reserved. Privacy Policy Terms and Conditions

http://developer.coronalabs.com/content/application-programming-guide-tutorial-introduction

Page 13 of 13

You might also like