OriginalArticle, Reprinted, please note:Reprinted from All-iPad.netLink:Corona 5-minute getting started
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, and now, of course, it has dropped to $149 (see here ). 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. You do not need to go through complicated compilation processes. You can use a simpler and interpreted Lua language to develop applications.
You can use your Windows PC to develop IOS applications. Of course, if you want to publish the app to the appstore, you still need an iMac or MacBook (Pro)
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 onCodeWrite, of course, you can find a graphical development tool 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 to demonstrate how to run the app. 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 to display the 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.
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 complicated debugger to understandProgramHow is it running now.
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:
Local textobject = display. newtext ("Hello World", 50, 50, nil, 24)
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. It's very convenient, isn't it.
Original article, reprinted Please note:Reprinted from All-iPad.net
Link:Corona 5-minute getting started