Apple Corona in 5 minutes Part 2
Animation and Sound
Let's animate the text and add some sound every time the user taps the button. Start with the “HelloWorld2” project and add the following lines at the end of main.lua
so that the text will move vertically down by 100 pixels:
transition.to( textObject, { time=1000, y=textObject.y+100 } )
讓我們的動畫文字並添加一些聲音每次用戶點擊按鈕。開始與“HelloWorld2“項目,並添加以下行末的main.lua使文字將垂直向下移動100像素:
Here, we are using the transition
library which does a lot of the heavy lifting on our behalf (seeAnimation).
We can add some sound by adding one line to the tap
object method:
在這裡,我們使用的是過渡庫,做了很多繁重的代表我們(seeAnimation)。
我們可以添加一些聲音,加入一行到水龍頭對象的方法:
function button:tap( event ) local r = math.random( 0, 255 ) local g = math.random( 0, 255 ) local b = math.random( 0, 255 ) textObject:setTextColor( r, g, b ) media.playEventSound( "beep.caf" ) end button:addEventListener( "tap", button )
Here we are using the media
library which provides multimedia support.
在這裡,我們使用的是媒體庫,提供多媒體支持。
You're All Set
So that’s it for the quick tour of Corona. There's plenty more to explore like using the accelerometer to create novel user interactions, getting GPS information to enable location-based functionality, storing data in a database, and much much more.
Hopefully, you've gotten a taste for how easy Corona makes it to create cool apps and games. If you want to learn more, head over to our Overview page.
Or, if you’d really like to dig into a book, check the book list for titles available for sale online or at your local bookseller.
就這麼簡單
所以這是它為快速瀏覽電暈。有很多喜歡使用更多的探索,創造新的加速度計的用戶交互,獲取 GPS信息,使基於位置的功能,數據存儲在數據庫中,以及更多。
希望你已經得到了一個簡單的味道如何電暈使得它創建很酷的應用程序和遊戲。如果您想了解更多,頭向我們概述頁面。
或者,如果你真想挖成書,查書目錄的產品可供出售網上或在當地書店。