13

Mobile App Development with Corona: Getting started – Hello World

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

Things you need:

Corona SDK (http://www.CoronaLabs.com),
iPhone SDK (http://developer.apple.com/ipad/sdk/) (if you want to publish to an iPad or iPhone)
And an editor (I’m using Xcode, but you could also use BBEdit, Eclipse with LuaEclipse, TextMate, Notepad or Corona Project Manager).

You don’t have to own any of this, you can easily get started with the trial version of Corona SDK and the trial version of the iPhone SDK.

Hello World
Ready to do your first program? Typically this is done as “Hello World”.
Open your editor of choice (I’m using Xcode 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 iPhone 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 Xcode (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!

Video Demonstration:
[tubepress video=”GmS82aHW9zc”]

Tags: , , , , , ,

13 Comments

  • Boy, we would sell our molars to get someone to help us continue developing our iPhone app “HerbStat.” The initial charge to get a 3rd party to do the app was very expensive and sales aren’t allowing us to do updates owing to that expense. It would be so nice to be able to update and add features using corona. What we need I guess, is help with using the database import and sort functions. Any input would be gratefully received. Thanks!

  • Dan Ellis says:

    If you are a solid lua programmer ; I would like to discuss some projects at my site’s chat. I am wondering if Corona could be used to program a music program thats more of an application than a game.

  • Dr. Burton says:

    @Dan,
    Yes, Corona could be used to create a music program app. As far as doing development, I do have a few students that might be interested in working on some projects.

  • mat says:

    can corona be used to build a client server application with a database back end ?

  • Dr. Burton says:

    Yes. I will be including an example in my next book on Corona development.
    Are you interested in client/server in game development or app development?

  • Nick says:

    Dr. Burton,

    You mentioned in an earlier post that you might have some students that would be interested in doing some extra work. Can you give them my email as well. I need to do some updates on my existing basketball stat tracker and wondered how much they would charge.

    Nick
    nick@intensemedia.com

  • Dr. Burton says:

    @Nick,
    I have forwarded your message to my students. They should be in touch soon.

  • Erik says:

    Hi Dr. Burton,

    I’m also looking for a developer or two. Can you forward my info to your students as well?

    Best,
    Erik
    ebowman@wbzlabs.com

  • emily says:

    This post is the really good for any new commer in iphone programming. Thank you and will wait for more information regarding the iphone development like.http://www.gamedevelopmentindia.com/

  • T. Wilson says:

    Hi, I would also be interested in discussing a project with a couple of your students. I am working on a cookbook app.

  • Anelie Ivanova says:

    Hi,

    Recently I came across some great articles on your site.
    The other day, I was discussing (http://www.burtonsmediagroup.com/blog/2010/06/iphone-game-development-with-corona-getting-started-hello-world/)with my colleagues and they suggested I submit an article of my own. Your site is just perfect for what I have written!
    Would it be ok to submit the article? It is free of charge, of course!

    Let me know what you think
    Contact me at anelieivanova@gmail.com

    Regards
    Anelie Ivanova

  • Abhay says:

    I was trying to create something that would record my voice and play it back to me immediately. ..without taking much time…kinda like the talking tom cat app….where the sounds don’t get stored in a folder…I have tried the media.startRecording but it doesn’t seem to be working out for me…might be doing something wrong there…can you show a tutorial on how to use the mic of the device to record sound…

  • iPhone Game Development with Corona: Hello World | Dream Later says:

    […] Learn how to develop software for the iPhone and iPad. In this demonstration, Dr. Burton show how to develop an app with Corona for the iPhone or iPad. You can view the complete tutorial at http://www.burtonsmediagroup.com/blog… […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © 2010-2019 Burtons Media Group All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.