5-minute introduction to Corona Development

Source: Internet
Author: User
Tags corona sdk

About Corona

If you are working on iOS applications or have been concerned about iOS development, you must have heard of Corona.

After Apple modified the app review policy and allowed the use of third-party languages to develop applications, Corona, a project that had to be used to crack the system, was finally noticed by more people, the price also rose from $99 to $299. Of course, it is now reduced to $149. but looking at his long Showcase list, it is not difficult to find that it is indeed a noteworthy engine.

To put it simply, the advantages of Corona are as follows:

◆ Complex Objective-C is not required, and complicated compilation process is not required. The simple and interpreted Lua language is used for application development.

◆ You can use your Windows PC to develop iOS applications. Of course, if you want to release an iMac or MacBook (Pro) to the AppStore)

◆ The perfect combination of iOS and Android platforms makes application porting no longer a nightmare

◆ Rich APIs and Integration of Third-Party libraries make application development easier and faster

Development Method

If you have downloaded and installed the Corona SDK, you should also note that there is only one Corona Simulator and one Terminal in the CoronaSDK directory, and there is a debuger without an editor. Yes, the development of Corona mainly relies on code writing. Of course, you can find graphical development Tools in the Tools on the Corona website. You can also try it.

There are also three ways to run the simulator:

◆ Run Corona Simulator directly. It is generally used for demonstration of app running. You will not see any printed error messages.

◆ Run Corona Terminal, which is the most common method for daily development. It will enable the simulator and display a Terminal window for displaying printed debugging information and error information.

◆ Run debugger. This will enable the simulator and a terminal with interactive functions. It can be used for debugging. Of course, you need to be familiar with debugging tools such as gdb.

When the simulator runs, find the main of the app you want to test from File-Open. when lua is opened, the app screen appears in the simulator window, and the terminal window displays printed information. Like this:

Hello World

The best way to learn is practice, so let's create an app from the simplest example. Yes, all examples are from "Hello world !" .

Use your favorite text editor to create a text file.

 
 
  1. print("Hello World") 

Save the file as main. lua. Note that the main file of the app must be main. lua. It is best to put all the related files of the app in a separate directory. In general, each app should have its own directory. For example, here we call Sample1.

Then, in the Corona Simulator File> Open, find the saved main. lua File and Open it. If everything goes well, you will not see anything. Yes, nothing can be seen! However, if you open a Simulator through Simulator, you can still see something in the terminal window, as shown below:

The Hello World is the one we just output.

Simulator vs Terminal

Our print ("Hello World") statement does work, but it does not show what we want. What we want is to output a line of text in the app, but now it is in the terminal window. So what is the difference between a simulator and a terminal?

In simple terms, the terminal window is mainly used to output debugging/warning/error messages. Although it is not seen in this formal app, it is very useful for our development stage, we don't need to use a complex debugger to understand how the program is running.

Hello World on the Simulator

To output text on the simulator interface, we need other functions, all of which come from Corona graphics library.

Here, we can do this:

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

Run this program on the simulator again and you will see the following results:

Yes, that's exactly what we want. The details of the above two lines of code are not described much. If you are a programmer, there is no difficulty. If you are not, well, the lua language is really not very difficult.

Note that the display. newText and textObject: setTextColor. The two functions are called. number, one is used: number, which is the two function call methods of lua language, or: Number call is actually. the syntax of the call is simplified. The detailed description still needs to be learned through the lua manual.

One of the advantages of using Corona SDK, or the advantage of using dynamic languages such as lua, is that you can easily see the modified results, instead of going through the compilation-link process like Objective-C. When you modify the main. lua file and save it, the Simulator will automatically remind you that the file has been updated, whether to re-load it, select "yes" to immediately see the modified effect. Of course, you can also take the initiative to re-load the app during the running process, using Command-R, you do not need to wait for compilation, you do not need to close the simulator and then re-open.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.