Você está na página 1de 7

Introduction to Corona SDK: Easy Cross-Platform Development

10/11/13 11:59 AM

Advertise Here

Introduction to Corona SDK: Easy Cross-Platform Development


Carlos Yanez on Aug 2nd 2010 with 9 Comments

Tutorial Details
Technology: iOS + Android Difficulty: Beginner Completion Time: 30 Minutes View post on Tuts+ BetaTuts+ Beta is an optimized, mobile-friendly and easy-to-read version of the Tuts+ network. Corona SDK is an excellent option for any kind of mobile developer from beginner to advanced. This tutorial will introduce you to this easy-to-use cross-platform framework and show you how to start creating content for your preferred platform.

Related Corona SDK Tutorials:


Introduction to Corona SDK: Easy Cross-Platform Development Corona SDK: Creating an Analog Clock App Corona SDK: Create an Accelerometer Driven Application

What is Corona SDK

http://mobile.tutsplus.com/tutorials/corona/introduction-to-corona-sdk-easy-cross-platform-development/

Page 1 of 7

Introduction to Corona SDK: Easy Cross-Platform Development

10/11/13 11:59 AM

The official Corona website describes the SDK as follows: Corona is a fast and easy development tool for iPhone, iPad and Android games and applications. Corona-powered apps run at 30 fps in as little as 300k, and the graphics and animation engine fully leverages OpenGL hardware acceleration. The Corona SDK is the first in Anscas Corona family of products for creating high-performance multimedia graphically rich applications and games for the iPhone. With Corona, you can quickly create iPhone applications in a matter of hours. No Objective-C/Cocoa required, and no C++. Ansca is the company behind Corona, and this SDK allows developers to create fast and powerful cross-platform applications that have access to APIs other frameworks dont, like the camera, GPS and Accelerometer.

Advantages

As mentioned before, Corona SDK offers plenty of features that make it a very reliable way to create applications. Some of these features are: Native Application Development: Corona executable binaries are 100% Objective-C/C++, so you wont have to worry about Apple iOS 4 new rules on using outside development tools. In fact, Corona needs Xcode to compile. Automatic OpenGL-ES Integration: No need to call extensive classes or functions to create simple screen manipulations. Cross-Platform Development: Corona can create apps for iOS (iPhone, iPod Touch, iPad) and Android devices. Performance: Corona is optimized to make use of hardware-accelerated features, resulting in powerful performance in games and apps. Device Features: Access device native controls and hardware, like camera, accelerometer, gps, etc. Easy to Learn: Corona uses the Lua programming language, which is powerful and easy to learn.

Disadvantages
As Ansca is not officially a part of Apple or Android, there are certain things that may be not available in recent releases of the
http://mobile.tutsplus.com/tutorials/corona/introduction-to-corona-sdk-easy-cross-platform-development/ Page 2 of 7

Introduction to Corona SDK: Easy Cross-Platform Development

10/11/13 11:59 AM

native SDKs. However, the people maintaining Corona are constantly adding new features as they become available. This is a problem for all cross-platform frameworks. Some examples of features not yet supported in Corona include: iAds Songs/Playlist Access Photo Libraries Access MapKit Custom Font Support Push Notifications

Supported Devices

The largest advantage of Corona is that it allow you to work with one code base and produce products for many different devices. Specifically, the Corona SDK will allow you to create apps for all iOS devices and Android devices.

Development with Lua

Corona uses the Lua programming language to create applications. Lua is a scriptitng language commonly used to develop games. It has a good amount of market adoption in the development community. Lua syntax can be compared to languages such as JavaScript or ActionScript 3, which makes it easy to learn. You can find out more about Lua on the official website.

Using Corona SDK


In order to use Corona SDK as your development environment you need the following:
http://mobile.tutsplus.com/tutorials/corona/introduction-to-corona-sdk-easy-cross-platform-development/ Page 3 of 7

Introduction to Corona SDK: Easy Cross-Platform Development

10/11/13 11:59 AM

Mac OS X 10.5.6+ (If developing iPhone apps, an Intel based Mac is needed for testing and App Store submission) 1 GB RAM 50 MB of hard drive space If you have a PPC based Mac, you can still create applications with Corona. However, you will only be able to test your apps in the Corona Simulator and wont be able to sell them in the App Store because Corona needs the latest version of Xcode to compile all iPhone applications.

Download Corona SDK


To start developing, go to the Corona SDK website and download a 30 day free trial.

Lua Editors

http://mobile.tutsplus.com/tutorials/corona/introduction-to-corona-sdk-easy-cross-platform-development/

Page 4 of 7

Introduction to Corona SDK: Easy Cross-Platform Development

10/11/13 11:59 AM

At this time, Corona doesnt come with an exclusive Lua editor, but there are some great editors already available that you can use: Free: Eclipse, using the Lua Eclipse plugin. LuaEdit, LuaEdit is an IDE/Debugger/Script Editor designed for the version 5.1 of Lua. NotePad++, a free source code editor which supports several programming languages, including Lua. TextWrangler, a powerful general purpose text editor and Unix and server administrators tool. Commercial: TextMate, Available for Mac OS X only. BBedit, a leading professional HTML and text editor for the Macintosh. Decoda, a professional development environment for debugging Lua scripts in your applications.

Creating Your First Program


To get started with Corona, lets begin with the classic Hello World application. Open your prefered Lua editor and write the following code:
print("Hello World!")

Create a new Project folder named HelloWorld and save the file as main.lua. Well launch this app in the next steps.

Terminal
If you come from a C like environment you will know that the print method outputs a string to the screen, you can test it by double clicking the Corona Terminal in the Corona application folder and selecting the HelloWorld project using the Open dialog.

http://mobile.tutsplus.com/tutorials/corona/introduction-to-corona-sdk-easy-cross-platform-development/

Page 5 of 7

Introduction to Corona SDK: Easy Cross-Platform Development

10/11/13 11:59 AM

This will also open the Corona Simulator displaying an iPhone graphic with no content, this is because the print function only outputs to the Terminal, to see how to display text in the simulator continue to the next step.

Simulator
To access the simulator or actual device screen, well need to make use of the Corona specific APIs. In your main.lua file write the following and then run the program again:
local myTextField = display.newText("Hello World!", 1, 20, nil, 14);myTextField:setTextColor(255, 255, 255);

Whats Next
You have created your first iPhone/iPad/Android application using Corona SDK in just a few minutes! Of course, theres still a long run to go if you want to build great and high quality applications, so stick around for more updates! Here are some additional links that will help you in the process of learning Corona: Programming in Lua An excelent book on Lua Programming Learning Corona The official Corona How Tos

Conclusion
Corona is very powerful and easy to learn, and these facts make it an excellent way to start or continue your software development no matter what platform you are building for.
http://mobile.tutsplus.com/tutorials/corona/introduction-to-corona-sdk-easy-cross-platform-development/ Page 6 of 7

Introduction to Corona SDK: Easy Cross-Platform Development

10/11/13 11:59 AM

Thanks for reading this tutorial, I hope youve found it useful!


Like 11 people like this. Be the first of your friends.

advertise advertise here here

By Carlos Yanez
Carlos Yanez is a freelance software developer/interface designer that enjoys the use of different technologies for creating content. When he is away from the keyboard he plays guitar/bass and runs a local social website.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more

http://mobile.tutsplus.com/tutorials/corona/introduction-to-corona-sdk-easy-cross-platform-development/

Page 7 of 7