Corona SDK 入門 part 1

Corona 是一個跨手機平台的SDK, 有免費版及付費版. 若你打算上架App Store, 就一定要用付費版. 官網

理論上可以用在商業程式或遊戲, 看過API後我認為比較偏遊戲開發.

Corona用的是Lua language, 是一種直譯語言, 在遊戲界應該尚算流行. 弱型別語言, 可以用類似物件導向的寫法, 但我覺得還是偏非物件導向, 要封裝及傳遞變數並不是很直覺.

開發環境我是用LDT, 設定上不算複雜, 但也繼承了一些Eclipse的毛病, 總是會遇到問題. 設定方法如下

1) Add a new interpreter for corona simulator in the Lua/interpreter preference page by selecting "add" and selecting the Corona Simulator 
executable as Interpreter executable, adding "-debug" to "Interpreter arguments" and uncheck the option "Accept -e as argument". 
2013-12-16_0004392013-12-16_000453 
2) You should still add the following code at the begging of your project: 
if (system.getInfo("environment")=="simulator") then
require("debugger")()
end 
2013-12-16_000630
3) Copy the debugger.lua file by clicking on the top menu
"Run/Debug Configuration" and then create a "Lua Attach to application"
launch configuration and click on the link "Lua Debbuger Client" and
select "Corona SDK/Ressources" folder. 
2013-12-16_000803
4) Then go to top menu "Run/Debug Configuration" and create a "Lua Application" launch configuration which will use the created Corona interpreter 
as runtime interpreter and launch it in debug mode.
2013-12-16_000837

來源

啟動LDT時記得用管理員權限, 不然你做上面4 steps時會有問題

UPDATE : Corona Editor 1.0 已推出, 自動完成功能 樂勝

每一個程式都要有main.lua, 裡面的variable 雖然用local宣告, 但我看文件覺得那其實是global. 因為Lua不需要main function, 所以main.lua裡的local, 其實整個main都可以用得到.

至於其他檔案看不看得到?要怎樣定義類別及分檔案?這就是我覺得lua很不物件導向的原因, part 2再續…

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s