2013年4月26日 星期五

看 Corona SDK DEMO 學 API


Corona SDK 做 Mobile App 非常快速,這主要要歸功於 Corona SDK 裡完整的 API (Application programming interface),但是要學習 Corona API 最好的方法就是看它所附的 Sample Source Code. 所以我也打算從帶您看 Sample Source Code 開始來入門 Corona SDK。 

我們之前看過了 HelloWorld 的程式,今天我們來看這叫 FrameAnimation1 的簡單範例:

(PS:這個 project 的資料夾在 Corona SDK 路徑下面 /SampleCode/GettingStarted/FrameAnimation1/ 裡面)



local background = display.newImage( "grass.png" )

local radius = 40

local xdirection = 1
local ydirection = 1

local xspeed = 7.5
local yspeed = 6.4

local xpos = display.contentWidth * 0.5
local ypos = display.contentHeight * 0.5
local fruit = display.newImage( "fruit.png", xpos, ypos )

-- Get current edges of visible screen (accounting for the areas cropped by "zoomEven" scaling mode in config.lua)
local screenTop = display.screenOriginY
local screenBottom = display.viewableContentHeight + display.screenOriginY
local screenLeft = display.screenOriginX
local screenRight = display.viewableContentWidth + display.screenOriginX

local function animate(event)
 xpos = xpos + ( xspeed * xdirection );
 ypos = ypos + ( yspeed * ydirection );

 if ( xpos > screenRight - radius or xpos < screenLeft + radius ) then
  xdirection = xdirection * -1;
 end
 if ( ypos > screenBottom - radius or ypos < screenTop + radius ) then
  ydirection = ydirection * -1;
 end

 fruit:translate( xpos - fruit.x, ypos - fruit.y)
end

Runtime:addEventListener( "enterFrame", animate );



首先我們先執行一下這個程式,很簡單,就是一個在螢幕裡彈來彈去的移動蘋果。好,那我們先看看 Corona SDK 模擬器裡有些什麼?




我只介紹重要的部分,第一是最右邊那個 Window 選單拉下來,可以看到 View As,選到以後可以選擇你要模擬的硬體裝置,從 iPhone / iPhone4 / iPhone5 / iPad 到各種 Android 裝置,還有 Kindle Fire / Nook 等等。這個重要的是讓你有機會模擬不同裝置,在螢幕不同解析度時,App 會有什麼現象。依我的經驗 iOS 可以幾乎 95% 沒問題,但是 android 還是用真正的手機去 test 最保險。

第二是最右邊第二個 Hardware 選單拉下來,可以讓你把裝置打橫(由 portrait 變 landscape),或暫時停止運行 suspend 等等。

第三是 File 選單拉下來,有一個 build ,讓你選擇把 App 打包變成可以傳到裝置上的格式。在 android 時是 .apk 的檔案,在 iOS 時是 .app 的檔案。還有 File 選單最下面倒數第二項,Show Project Sandbox 項目,是讓你看看萬一有資料要存到裝置裡面,它模擬出一個儲存空間,讓你看到裡面存檔資料運作的情形。

接著,我們來看看『程式部分』,有兩個重點:第 35 行:
Runtime:addEventListener( "enterFrame", animate )

這個 API 呼叫是說,在 Runtime (也就是 LUA 程式執行起來之後),把 animate 這個 function ,在每個 "enterFrame" 訊息被系統收到時都執行一次。在沒有特別在 config.lua 裡面作不同設定的情形下,Corona 會以每秒三十個 Frame 的方式送這個 event 事件給你的程式,也就是說你的程式會像有個時鐘在跑一樣,每 1/30 秒就執行一次第 21 行 animate 這個 function。

另一個重點,第 32 行:
fruit:translate( xpos - fruit.x, ypos - fruit.y)

這裡, fruit 是一個 graphic 物件 object,這個物件有一個叫 translate 的方法,可以把它圖像的座標,從原來的位置移到 x 座標 = xpos - fruit.x, y 座標 = ypos - fruit.y 的位置去。

所以你就看到一個在螢幕裡彈來彈去的移動蘋果,很簡單吧。下回我們再看更精彩的。

待續...






2013年4月21日 星期日

再說說 CORONA SDK 與 LUA 語法



CORONA SDK starter 完全免費,不用懷疑
從2013年4月4日星期四開始,Corona SDK 推出 starter 版本,它把以往『開發測試 加 build to device 免費,但是上架到 store 時要付錢』的方式,改成現在連上架也免費。以前的方式是若沒付錢,會加一個提醒訊息在程式啓動的時候,現在 starter 版本已經不會這樣了。趕快加入 Corona SDK 開發者的行列吧!

上次講到 LUA 的 table 還有 Corona 的 API 呼叫,我接下來要介紹 LUA table 的一些用法,實做就像這樣:

問題1: API 要的是 table 我傳給他的卻是個 value 值?
以後你會常常遇到,Corona SDK 有個很好用的 API 叫 timer.performWithDelay( delay, listener [, iterations] ),它的功能是讓程式等待個 delay 的時間,再去呼叫執行 listener 這個 function,然後重覆 iterations 次。

我有個剛學 Corona SDK 的朋友,他把一段問題的 code 給我看,我發現會有這種誤會。也就是說例如:

print("start!")
local function run()
  print("I am running.")
end
timer.performWithDelay( 3000, run() )
print("end!!")


會得到的結果

start!
I am running.
end!!

這個跟你寫 timer.performWithDelay( 3000, run ) 的結果是不一樣的。

start!
end!!
I am running.

我們要的是第二種結果才對吧?所以你要弄清楚 run() 是呼叫執行它,而 run 則是把 run 這個函式的對應 table / pointer 傳給它。

問題2: 我們可不可以自己來做一個像 Corona 那樣的 API 呢?我們看一下,假設我有一個叫 smile.jpg 的圖,我想把它放在螢幕的中間,那 Corona 程式是這樣寫的

local background = display.newImage( "smile.jpg" )
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2

如果我想仿照上面的 display.newImage,我想寫一個叫 display.newSmile 的 function ,只要我告訴他 who 它就列印 who smiled. 然後我可以告訴他 who 是 who (像上面 background.x = 某個值這樣) 這該怎麼做呢?看看下面的程式:

local function Smile( who )
  print(who .. " smiled.")
end
local display = { newSmile = Smile, who = "Ted", }
display.newSmile(display.who)
display.who = "Bob"
display.newSmile(display.who)

PS: LUA 可以用 .key 來取用 table 的值,他跟用方括號陣列方式取用有相同結果,例如 table a = { x = 10 } 相同於 table a = { ["x"] = 10 } 而 a.x = 10 也是 a["x"] = 10

這裡告訴你說,你不但可以放值在 table 裡面,你也可以把 function 放到 LUA 的 table 裡面。
所以我們知道 Corona 的 API 事實上也只是一些 table 而已,你只要知道 table 有哪些 key 就可以很容易抓住它的精華。


順帶一提,定義 table 裡面一個接一個的初始值,你可以接一個逗號在最後面 local display = { newSmile = Smile, who = "Ted", },『..."Ted",』 逗號沒有跟著下一個初始值是允許的。這樣你看 Corona 的 sample code 時候比較不會覺得奇怪。


問題3: 那麼冒號 : 存取 table 的 function 又是怎麼回事?看看下面的程式:

local ndisplay = {}  -- 若取名 display 會蓋過原來的 table 造成問題喔!
ndisplay.who = "Bob"
function ndisplay:newSmile(who)
  if who then print(who .. " smiled.") end
  if self then print(self.who .. " likes bowling.") end
end
ndisplay:newSmile(ndisplay.who)
ndisplay.who = "Tom"
ndisplay:newSmile(ndisplay.who)

其實 LUA 原本是建議我們用冒號 : 來存取 table 的 function,這也最正確的方式。
換個物件導向的程式說法,就是說我們用 . 存取 property 用 : 存取 method。(哈!雖然 LUA 不是物件導向語言)
如果在 LUA 裡面你不這樣做,你可以試試再加上下面這些程式碼

ndisplay.newSmile(ndisplay.who)
-- 上面這一行無法正確執行,會有語法錯誤 input:5: attempt to concatenate field 'who' (a nil value)
-- 若詳細查 LUA 的書,你會發現用 : 定義的函式,若以 . 呼叫,這呼叫方法會需要帶 self 這個參數進去才能正確執行

ndisplay.newSmile(self,ndisplay.who)
-- 上面這一行可以正確執行,因為我們有傳了 self 進去
-- 但是用 : 定義的函式,若以 . 呼叫,雖然我們把 self 傳進去,但是它函式裡面也收不到這個值

之後,我們開始講 Corona SDK 的 API 繪圖物件時,常常要呼叫 obj:removeSelf() 來清除物件和物件佔去的記憶空間。你就
不會覺得奇怪,為什麼不是用 obj.removeSelf() 了。

...待續

2013年4月17日 星期三

CORONA SDK 與 LUA 語法





我們在前面說過,Corona SDK 用來開發行動應用的程式語言是 LUA 語言,所以對於新手要開始學 Corona SDK ,那就一定要學 LUA 語言。就我個人半路出家的經驗,我在學 LUA 語言之前,我會的是 BASIC, C 這種老舊的程式語言(抱歉,我有點歲數了)。後來在網際網路開始盛行後我自學了 PERL, PHP 等等語言。後來為了開發行動應用,也讀了一些 Objective-C 跟 Java 的書。我發現你只要有程式邏輯在腦海裡,用什麼語言來開發倒是沒差很多。我剛開始在 Corona SDK 文件還不齊全時,就摸索學習使用這套工具開發,主要的原因是我希望可以只維護一套程式碼,就可以在不同的平台上做 APP,也因此我選了 Corona SDK,就這樣有多學了一種 LUA 語言。

言歸正傳,我要引導你快速入門 Corona SDK,我要說 LUA 語言就只說重點,LUA 的重點是 Table,弄懂了 Table 就幾乎可以寫程式了。那什麼是 LUA 的 Table 呢?我這樣說比較有趣,想像 Table 就像一個銀行,它可以存很多東西,古時候希臘人去銀行存東西,管理人就把一片瓦片打破成兩片,然後你一片,管理人一片。等你要來拿存的東西的時候,大家一比對,裂痕合的起來的就對了,可以領走東西。這個瓦片叫做 KEY,意思是說有了 KEY 才能存取你要的內容。所以英文這樣說:
An item in a Lua table consists of two things: a key (the authenticating token) and a value (the goods deposited).
你說,那這不就是陣列 Array 嗎?隨便想你怎麼叫它,我沒意見,倒是使用它的方法,卻有規定。我們來看看下面這段 LUA 的程式碼:


-- 他說 t 是一個 lua table 裡面有兩個 key 叫 "heinz" 跟 100
-- 還有兩個 value 是 57 跟 true。
t = { ["heinz"] = 57, [100] = true }
-- 這跟下面這樣寫是相同的
t = {}
t["heinz"] = 57
t[100] = true

PS: 給您提供一個網路上的好東西,讓可以在你的瀏覽器裡面跑 LUA 程式 => http://www.lua.org/demo.html 。然後你可以把這裡的示範打進去(或 copy paste 一下),就可以看到結果。

那如果程式這樣寫

t = { ["heinz"] = 57, [100] = true, 300 }
w = { ["heinz"] = 57, [100] = true, 300 }
u = t
print (t == u)
print (t == w)
print (t[1],t[100])


那前面那個 print 的結果是 true 後面則是 false,因為 Table 是一個指標(pointer),t 和 w 是不同的指標。至於第三個 print 就有趣了,t[1] 的值是 300,t[100] 的值是 true。你早知道這結果了對不對?原來 LUA 是允許宣告時不給 key 的,而當你不給 key 的時候,它就自動從 1,2,3,4.... 的順序排列給一個 key。所以那個 t = { ["heinz"] = 57, [100] = true, 300 } 的第三個值就是當成沒有給 key 的情況,系統自動給了一個 key 1。這個原則也反映在函式呼叫時候,參數的傳遞。(LUA 可以在函式宣告時說需要哪些參數,但你可以選擇不傳某些參數過來,而不會發生錯誤。還記得前一篇那個 display.newImage() 的 API 呼叫說明嗎?裡面就有用方括號括起來的參數)

要不要自己動手一下,到上面說的那個網站去試看看。

待續...


2013年4月15日 星期一

Corona SDK API 介紹


我們知道利用 Corona SDK 做 Mobile App 非常快速,其實這主要要歸功於 Corona SDK 裡完整的 API (Application programming interface),我們知道我們的行動裝置上面有許多功能不同的硬體,例如:觸控螢幕就是一個例子。我們每天觸控螢幕上點來點去,滑左滑右,如何寫程式來支援觸控螢幕的回應,還有更多其他不同的硬體設備,絕對不是一個 LUA 語言就能做到的事。還好 Corona 已經幫我們做好了超過 500 條的 API 讓我們的程式來呼叫調用,幾乎百分之九十你想得到的功能,都能透過這些 API 來達成。

讓我們來看看上一回提到 Hello World 這個 project 的例子:

local background = display.newImage( "world.jpg" )

我們打算在行動裝置的螢幕上秀出一張圖檔,我們可以利用 Corona SDK 裡面的 display.newImage 這個函式 function。Corona 裡面對於要輸出到螢幕上的作業,大多收集在 display Library 函式庫裡面,我們可以用 display.* 『 * 是代表你要用的函式,例如前面的 newImage』 來呼叫。(為什麼用 display.* 呢?這有相關到 Lua 的語法,我們改天會說到)

你可以到這個網址連結 http://docs.coronalabs.com/api/library/display/newImage.html 去看有關 display.newImage 的呼叫方法

網頁上的文件說,它可以接受像下面這樣的一些參數

display.newImage( [parentGroup,] filename [,baseDirectory] [,left,top] [,isFullResolution])

第一個參數 [parentGroup,] 放的是這個要秀的圖檔,是否屬於某個 parentGroup 圖形群組。
PS:這裡用方括號刮起來,表示是選擇性的項目,也就是可有寫也可沒寫的參數。

第二個參數 filename 檔名,就是在 project folder 裡面圖檔的名稱。

第三個參數 [,baseDirectory] 路徑,圖檔存放位置的路徑。
PS: 一般我們行動裝置上有三個不同的路徑可以存取檔案,第一個是 system.ResourceDirectory 也就是指 project folder 裡面。(注意:這個路徑是只能讀不能寫的)另一個是 system.DocumentsDirectory ,這個是你應用程式安裝到行動裝置上後,行動裝置系統分配給你這個應用程式可儲存空間的路徑。(注意:這個路徑是能讀也能寫的)最後一個是 system.TemporaryDirectory ,這個是行動裝置系統分配給你這個應用程式另一個可儲存的空間路徑,只是這個空間,系統有可能會動態收回,所以不建議存常態資料。

第四與五個參數 [left,top] 圖檔要放置的 X,Y 座標。

第六個參數 [,isFullResolution] true 或 false,如果你的圖檔要以完整像素一比一讀入系統的話,就是 true。否則系統若遇到比裝置像素還大的檔案,它會縮放這個圖檔。
PS: Corona 允許你讀取最大 2048 x 2048 像素的圖檔,它可以是 JPG 或 PNG 格式,其中 PNG 格式還支援有透明度的 alpha channel。

經過這樣一番解釋,是不是多了解了一點 Corona SDK 的 API 了呢?下次寫 Corona 程式,只要把網站 API 文件放在手邊,是不是很就快能上手了呢?

下次我要來講一講 LUA 這個語言,在寫 Corona 應用程式時要注意些什麼?

待續...



2013年4月14日 星期日

CORONA SDK 裡的 build.setting 和 config.lua


相信你一定玩過消方塊 Bejeweled Blitz 與植物大戰殭屍 Planet vs. Zombie ,這兩個膾炙人口的遊戲鼻祖是 Popcap 公司,他們公司的 Giordano Contestabile 曾說:If you look at the mobile market, and you look at the top games on iOS, 75 percent of them are made by independent developers. Mobile is a space where the barrier of entry is much lower, and there's much more opportunity for independent developers to play. 他說百分之七十五在 iOS 平台上的熱門遊戲都是獨立開發者 independent developers 而不是大型電玩公司做出來的。因為行動開發的市場門檻是那麼的低,所以給獨立開發者大的機會在這個市場上展露頭角。不用懷疑,只要你有好的點子,Corona SDK 可以幫你以十倍速的效率達成目標。趕快加入 Corona 的開發行列吧。

這次我們要來看 Corona Project 裡面的三個重要檔案。

首先第一個是 main.lua

Corona SDK 用來開發行動應用的程式語言是 LUA 語言,LUA 是葡萄牙語中「Luna」(月亮)的意思。它被發明出來是要成為一個很容易嵌入其它語言中使用的語言。所以它的特色是小,便捷,嵌入 (這目標聽起來很像 JAVA 語言是不是?) 最早的 LUA 體積小、啟動速度快。它用標準 C 語言編寫並以原始碼形式開放,編譯後僅僅一百餘K,可以很方便的嵌入別的程式裡。這個 main.lua 就是整個 project 的核心程式,也是未來我們要撰寫程式最主要的檔案。等一下我們再來看 Hello World! 它程式的內容。

第二個是 build.settings 檔案

這個檔案裡放著 Corona Project 最後要編譯到用戶裝置裡面時,一些與目標平台(我指的是 android 或 iOS)相關的設定值,例如:在 android 系統上你需要得到的授權 permissions,或是像在 iOS 平台,針對 iPhone/iPad/iPhone5 等不同裝置上要顯示的 Icon 圖檔等等。另外,你的應用程式是『直式』portrait或是『橫式』landscape,也是在這裡設定。

settings = 
{
 iphone =
 {
  plist =
  {
         CFBundleIconFile = "Icon.png",
         CFBundleIconFiles = {
            "Icon.png", 
            "Icon@2x.png", 
            "Icon-72.png", 
         },
  },
 }
}

第三個是 config.lua 檔案

這個檔案裡放著一些你程式執行時要用到的設定值,例如:
動態內容縮放 Dynamic Content Scaling。
動態內容對齊 Dynamic Content Alignment。
動態內容屬性 Dynamic Content Properties。
動態圖形解析度 Dynamic Image Resolution。等等
Dynamic Content 技術是 Corona SDK 為了配合各種不同裝置,不同營幕尺吋,所提出的解決方案。譬如:早期 iPhone 剛推出時是寬乘長各 320 x 480 個像素(點)的裝置,到現在 iPhone5 上面已經有寬乘長各640 x 1136 的像素(點)。如何寫一套程式,就能滿足各個不同裝置的解析度,這個 config.lua 設定有很大的幫助。

application =
{
 content =
 {
  width = 320,
  height = 480,
  scale = "letterbox" -- zoom to fill screen, possibly cropping edges
 },
}

那麼,我們的 Hello World! 主程式,到底寫了幾行呢?不用驚訝,在模擬器跑的這個程式只用了五行。


 local background = display.newImage( "world.jpg" )
 local myText = display.newText( "Hello, World!", 0, 0, native.systemFont, 40 )
 myText.x = display.contentWidth / 2
 myText.y = display.contentHeight / 4
 myText:setTextColor( 255,110,110, 120 )


第一行:設定一個變數 background 把我們的背景(在 HelloWorld 資料夾裡的地球圖 world.jpg)秀出來。
第二行:設定一個變數 myText 把 "Hello, World!" 這個文字字串用系統字型 native.systemFont,40點大的字體秀出來。
第三行與第四行:把文字顯示的位置移到顯示裝置 x = display.contentWidth / 2 跟 y = display.contentHeight / 4 的地方。
第五行:把文字顯示顏色設定成 (r,g,b) = (255,110,110),透明度設定成 alpha = 120。

看到這裡,你可能有一些疑問?什麼是 display.newImage, display.newText, display.contentWidth, display.contentHeight 呢?
沒關係,下一篇我會繼續說下去...

待續...



Hello World! 用 Corona SDK 實作


話說回到西元 1997 年,網際網路上的網站數量那時候第一次超過百萬個。哇100萬耶,真是個不可思議的數字,Google、Facebook、Wikipedia 這些著名網站也還沒出生哩,人們想像不到十幾年後的今天,網站數會有 5 億個之多。所以今天我們聽見有 70 多萬的 Android 應用程式、100 萬的 iOS 應用程式也不用奇怪,要知道,劃時代的行動紀元才剛剛要開始。你準備好當一個『行動應用開發者』了嗎?趕快來學 Corona SDK 吧!

來吧,先到 Corona 網站註冊一個會員,

http://www.coronalabs.com/ 點選右上角的 Sign-in ,選好自己的登入 e-mail 跟密碼,在 Terms and Conditions of Use. 打個勾,按 continue 就行了。



然後下載一個 Corona SDK 就可以開始了。

https://developer.coronalabs.com/downloads/corona-sdk ,這裡要選好自己的環境,也就是看你是用 Mac OS or Windows PC,請選擇你要用的下載就好。

PS:我因為使用的是 Mac OS 的電腦,所以往後的例子我都以 Mac 環境為主,你若遇到問題可以到社團裡問我。

好了,當你下載好了 Corona SDK,並在你的電腦把它解壓縮,並放到你的應用程式群組裡面後,你就可以開始創作你的行動應用程式了。

不能免俗的,我們來看看如何在行動裝置上做一個 Hello World! 的程式吧。

我們先打開 CoronaSDK/SampleCode/GettingStarted/HelloWorld 資料夾

你會看到夾子裡有三個重要的檔案,他們是 build.settings / config.lua / main.lua



Corona SDK 的世界裡面,一個 project 專案,就是一個檔案夾 folder,檔案夾裡只要有這三個檔案,它就可以執行。例如:我們現在如果要執行這個 HelloWorld 的專案,我們只要先執行 Corona Simulator 的模擬器環境,接下來選 Simulator 模擬器,它便會要求你給一個檔案夾來開啓,這時候你選擇剛剛我們說的那個 HelloWorld 資料夾,就可以看到模擬器在你的電腦螢幕上跑出一支 iPhone,然後裡面有一個地球,上面寫著 Hello World 的文字。

很簡單吧!試著開幾個不同的 Project 來看看 Corona SDK 有哪些強大的功能。下一次我再來講上面提到的那三個檔案是什麼用途。

待續...


2013年4月7日 星期日

Corona SDK 的六個 W



你想開始要使用 Corona SDK 來開發 Mobile App ?沒問題,我來教你。但是就在你開始之前,你有些事必須知道,所以我要先來說說 Corona SDK 的六個 W,當做引言。也就是

1. What is Corona SDK?

開宗明義,官方告訴我們 corona SDK 是一個頂尖的行動應用開發的軟體工具 "Corona is the leading mobile app development framework",這裡所謂的 framework 是指 consists of a software framework used by software developers to implement the standard structure of an application. 也就是說它包含了組成一個行動應用的標準的軟體架構,這個軟體架構 Software framework, a reusable set of libraries or classes for a software system (or subsystem) 指的是在 Corona SDK 裡面,讓你可以輕鬆完成工作,超過五百條內建的 API。(API : application programming interface)

2. Where is it comes from?

Corona SDK 來自美國矽谷,是有創投支持的新創公司 Corona Labs Inc. 所開發維護。Corona Labs Inc. 改名前曾經叫做 Ansca Mobile 公司。
Corona Labs is a venture-backed company based in Palo Alto. USA

3. Who created it?

Corona SDK 是由亞裔 Walter Luh 及拉丁裔 Carlos Icaza (2012 離開) 所創辦。他們之前都在 adobe 公司工作,富責 flash lite 項目。Walter Luh 當還在 adobe 時是首席架構師,所以他熟知行動應用的生態,工具以及平台,也是因此他離開 adobe 創業,選擇的就是做一套綴簡單容易使用的開發工具 Corona SDK。整個 Corona Team 的成員,多有經驗來自像 Adobe, Apple, Macromedia 和 Microsoft 這種大公司。

4. When is it available?

在 2009 年六月,第一版的 Corona SDK beta 正式在市場上出現。它是以免費的方式給一些人試用。到了 2010 年四月,Corona SDK 2.0 beta 才正式上市,並開始收費。作者我在 2010 年底開始使用 Corona SDK,並在 2011 年初正式成為 Corona 的付費用戶 pay subscriber。

5. Why you need Corona SDK for mobile app development?

使用 Corona SDK 的好處很多。舉例一些如:

Develop apps 10x faster
 因為容易使用及撰寫,你所有更改的程式效果,幾乎可以立刻看見。Corona SDK 提供包括 Windows 及 Mac OS 電腦上的模擬器,任何人只要到官網免費註冊一個帳號,就可以立刻開始寫程式,產品裡提供 500 條以上 API 功能,原本需要幾百行的程式碼才可以完成的程式效果,在這裡也許只要三五行。而且你可以幾乎馬上看到程式的成果,而不像其他開發工具,要等待冗長的編譯與連結程式庫。 

Go cross-platform with ease
 相同的一組程式碼,可以編譯成在 Apple iOS 平台上執行的應用程式,也可以編譯在 google android 平台。當然它還包含了 Amazon 的 kindle 平台及B arnes and Noble 的 Nook 平台。

Leverage industry standards
 Corona SDK 採用軟體業界的標準套件,例如 OpenGL, OpenAL, Google Maps, Box2D physics, Facebook Connect, Game Center, in-app purchases 等等。

不用擔心 android 上千種裝置的相容問題
 Corona SDK 已經為大家測試好各種 android 裝置,讓你不用因為裝置或 android OS 版本的不同,花費很多心力在實機測試上。

當然還包括 Community, Events, Resources, 3rd Party Tools 等等說不完的好處。

6. How to use...

所以以後的篇幅要講的,就是如何使用 Corona SDK 來變成一個『行動應用』開發者。

心動了嗎?讓我們馬上行動,立刻就來體驗 Corona 十倍速開發 Mobile App 的快感吧。

...待續

2013年4月4日 星期四

加入潮流變成一個『行動應用』開發者吧!


使用 CORONA SDK 開發 APP 已經有好幾年了,看著這個產品從草業初創天天更新日日補丁的系統,變到現在穩定快速,日流量上億次,用戶蒸蒸日上。整個見證了一個 Mobile App 的開創紀元。由於我是台灣最早一批的 Corona 開發者 (若不是第一也應該是前五名) ,所以我就向原廠要了一個大使的頭銜 Ambassador ,自動自發的幫忙在台灣推廣這個開發工具。拜 Mobile App 的大浪潮所賜,到現在 CORONA SDK 已經有數百名的台灣用戶。

>> 歡迎您加入臉書的 CORONA 社團
https://www.facebook.com/groups/corona.taiwan/

就在今天,CORONA 又做了一個勇敢的大挑戰,推出 Corona SDK starter 版本,以及許多新的功能。我相信就像『行動應用』這個市場一樣,我們都處在一個即將爆發的科技大潮流裡,歡迎大家都跟我一樣,加入潮流變成一個『行動應用』開發者吧

在 CORONA SDK 中文資訊相對不足的台灣,我會努力將 CORONA『行動應用』開發者所應該獲得資訊,儘量中文化後提供給大家,讓台灣開發者也能與世界同步,一起用 CORONA SDK 開發出可以改變世界,改變人們生活的 APP 來。

讓我就從導讀 Corona 創辦人 Walter 的這篇文章,當作一個開始吧!





 Posted on . Written by  
Today, I have some very exciting news.
Before I dive in, let me talk about the new public release we just made available for download. We’ve been fixing a lot of plumbing this time around. Lots of infrastructure and feature improvements like a rewritten async http network library, a re-architected widget library, remote push notifications on Android, iAds, to name a few. We also have a new build server that’s much more scalable.
>> 最新版 CORONA SDK build 1076 已經可以下載了,新的功能包括 2.0 的 network library, widget library,Android 上面的 push notifications,iOS 上面的 iAds 等等。另外因為 Corona 每次 build 都要連到伺服器,所以官方也把伺服器換成一個可以因應流量 scalable 擴大的方案。
There’s tons more listed on the release notes. All in all, there’s been an incredible amount of work to make cross-platform development as painless as possible. By the way, if you’re curious about Apple’s May 1 deadline on UDIDs, we’ve got you covered. Read more about it in the release notes.
>> 最新版 CORONA SDK 在出版文件上已經把新功能作了完整說明,最重要的還包括了 Apple 在 2013-05-01 以後禁用 UDID 的事件, Corona 這次也提出了解決方案。
big-news

Introducing Corona SDK Starter

Okay, so here’s where it gets really exciting. From very early on, we have focused on democratizing app development. We felt (and still do) that anyone could create the next great app with Corona. Since then, Corona has been embraced by indies and your apps have hit the top of the charts.
Indies are a key part of our community, so today, we are taking that vision a step further. We are announcing Corona SDK Starter – a completely FREE version of Corona that lets you publish to all the platforms we support without paying us a single cent.
With Corona SDK Starter and the Starter tier of Corona Cloud, you can publish amazing, connected apps faster and more affordably (free!) than ever before. We are the only platform that lets developers do this. A lot of other products have hidden fees or force some sort of watermark/splash screen. There is no such restriction with Starter. That’s the difference between “fake free” and a true free option.
>> 因為個人開發者一向是 Corona 的最大支持者,所以這次官方推出了 Corona SDK Starter 版本,最大的特色是『完全免費』,不管是 iOS 或 android 或 Amazon Kindle 或 Nook。不像其他某些工具(我猜是指 Unity)限制了免費版無法擁有自己應用程式的開機畫面 Splash Screen 或在開機畫面上放浮水印,這個 Starter 版本沒有這種問題。
Now, of course, not everything is free — we’ve got a business to run after all!
If you want to access certain specific features like in-app purchase and analytics, you’ll need to subscribe to a paid plan. You can still build with those features on your own device, but you can’t publish apps to the store if they use those premium features. Daily builds are also only available to paying subscribers.
>> 不過天下還是沒有白吃的午餐,一些像 in-app purchase 程式內購買,analytics 用戶行為分析,daily build 等等功能還是要付費的。(這裡則是維持以前的方式,在自己裝置上測試時免費,要 build 到 Play/App store 時,才要付錢)

Re-imagining Pro

From the beginning, Corona SDK has been about packaging up industry-standard technologies that big game studios use and making them available to you. The same underlying architecture that powered all the original top apps (Angry Birds, Tap Tap Revenge, Diner Dash) was the inspiration for Corona — only we made it 10x faster and easier.
That’s why nothing beats Corona when it comes to its combination of power and speed of development.
Today, we are ready for the next growth spurt of innovation. We think Corona is the best platform in the universe, but the true measure is if we can make our latest innovations available to Pro subscribers.
So that’s what we’re going to do. We are going to make some amazing technologies available to all paying subscribers, but especially Pro. Here’s a glimpse at some of the exciting things that we’ll be making available:
>> 對於已經付費,或未來願意付費的用戶,官方的誠意是推出一系列更強大的新功能,例如:
imagine

Graphics

As I talked about last week, our bleeding-edge OpenGL-ES 2.0/shader-based graphics engine is in the works. You are going to be blown away with what you can do. I’ll talk about that more later but I did want to give you a teaser.
If you watch this week’s CoronaGeek episode, you’ll be able to see 5,000 fish running at 60 fps! It may be hard to tell from the video, but this is what I showed to a lucky few at GDC. I recommend watching the whole show, but if you’re pressed for time, you can skip to roughly the 35:00 mark.
>> 1. OpenGL-ES 2.0/shader-based graphics engine 超高速的繪圖效能。 Corona 在 GDC 有個 demo 可以在裝置上畫出 5000 隻動畫游魚,以每秒 60 格的速度移動。

Plugins

Second, there’s Project Gluon, a.k.a plugins. We’ve done a ton of plumbing work so that you’ll be able to integrate 3rd party services and functionality into your app, and do so painlessly from the comfort of the Corona Simulator.
Now there’s good news and bad news here. There are a lot of moving parts, so plugins didn’t quite make it to the public release — and yes, I’m disappointed too.
But the good news is that plugins are coming very soon! We’re getting ready to seed this to beta testers this month. We are actively building a library of plugins that will be hosted on our servers. We’re working with folks like Amazon to get you more monetization options. We are acutely aware that this is a big issue for a lot of you.
>> 2. 好消息!以前 Corona 無法串接第三方程式庫的問題,這次以 Plugins 的方式解決了。以後你要接 adMob 或其他網路廣告商的程式庫,或你要接『藍芽』接『人臉識別』等等,都能解決了。壞消息是這個功能還要再等一下子,在 build 1076 是還沒有弄好的。(本月會有人有機會測試到這部分)

Device Access

Lastly (for now), we have found a way for you to access certain Java and Objective-C APIs from Lua! On the Android side, we already have the foundation there thanks to Enterprise, and we’re looking at how we can accelerate bringing those Enterprise innovations down to Pro developers. In parallel, we also have a proof-of-concept on the iOS side, so I’ll have more news once we’re past the research phase.
>> 3. Corona 找到透過 Lua 取用 Java 和 Objective-C API 的方法,目前在 android 上面很成功,相信在 iOS 上也是可以的。未來這都會開放給付費用戶。

New Pro Pricing and Subscriber Promotions

As you can see, we are re-imagining Pro as a much more sophisticated product. By May, we anticipate that the daily builds available to Pro will offer significantly more value than they do today. Because of that, we will be changing the price of Pro to $599/year starting May 1. Even after this change, we think Pro still remains a great bargain – it’s less than $50 per month and saves you hours of development work each and every day. And more importantly, you’ll be able to do more and more!
In the mean time, we want to thank our current subscribers and do the following:
  • All current Indie subscribers are now upgraded to Pro (the Indie subscription has ceased to exist).
  • All current Pro subscribers now have an extra 2 months added on to their subscription.
>> 新的變革還包括費率調整。現在起原來買 Indie 版的用戶(就是付 $199 只買一個 android or 一個 iOS 平台授權的),現在都升級到 PRO 版(雙平台),原來 PRO 版的用戶則獲得多兩個月的授權期限。然後從二零一三年五月一日起, PRO 版一年的授權費用要從 $399 調整為 $599。
In addition, we are offering a special promotion:
  • Between now and April 30, anyone can buy a Pro subscription (or add to their existing subscription) for $349 before the new price takes effect.
  • But wait there’s more. As long as you have an active subscription on May 1, you will be able to renew at the $349/year price for 2 more years — just don’t let your subscription lapse!
>> 新的促銷(『補償』)方案則有:在四月底前還是可以用 $349 買到 PRO 版。然後所有舊 PRO 版用戶(指在2013/5/1授權還有效的用戶),在未來兩年的續約價都維持在 $349 一年。
For more info, please refer to our Corona SDK Pricing FAQs.
* * *
Before I wrap up, there is one more item worth mentioning: we’ve finally gotten around to putting Corona Enterprise on our store page. If you are a small outfit, you qualify for the $999/year tier. Larger organizations can get Enterprise at $2499/year which comes with extra goodies and volume discounts. Check out our entire pricing lineup to see which one makes the most sense for you.
There’s a lot of game changing stuff here, but Corona SDK Starter brings me back to how we all got started — to change people’s lives in real ways. We think more people will have the opportunity to be a part of the mobile revolution and take advantage of the mobile revolution. We can’t wait to get all of our innovations into your hands – and more importantly, see what you do with them.
Walter

>> 最後 Corona 的企業版也以 $999/年 跟  $2499/年 的方式正式推出。這兩者的差別,主要是在技術支援上面,費用高的版本,可以有郵件保證回覆的技術支援。



-- 希望這個部落格能達到一定的推廣 CORONA SDK 的效用,更希望獲得您的支持。

Bob Yeh 葉浩銘