2014-08-27 72 views

回答

0
local widget = require("widget") 
local function Restart(event) 
    if "began" == event.phase then 
     --code here when touch begin 
    elseif "moved" == event.phase then 
     --code here when move 
    elseif "ended" == event.phase or "cancelled" == event.phase then 
     --code here when touch end 
    end 
end 

-- Create the widget 
local button1 = widget.newButton{ 
    left = 100, 
    top = 200, 
    id = "button1", 
    label = "Label", 
    onEvent = Restart 
} 

http://docs.coronalabs.com/api/library/widget/newButton.html 你可以看看它。

順便說一句,重新啓動您的遊戲不要忘了初始化變量&時顯示。*(如display.newGroup()/ display.newImage()等)