コロナタッチリスナーには、次の3つの状態があります。
function listener(event)
if event.phase == "began" then
-- in the 1st tap the phase will be "began"
elseif event.phase == "moved" then
-- after began phase when the listener will be called with moved phase,like touched coordinates
elseif event.phase == "ended" then
--when the touch will end
end
end
nextButton:addEventListener("touch", listener)
-[[これは、画像、自作ボタンなどのシンプルなタッチリスナーでした。ボタンが必要な場合は、この http://developer.coronalabs.com/code/enhanced用に作成されたUIライブラリを使用してください。 -ui-library-uilua ]]
-- example for usage
local ui = require "ui" -- copy the ui.lua to your apps root directory
yourButton = ui.newButton{
defaultSrc = "menu/icon-back.png",--unpressed state image
x=85,
y=display.contentHeight-50,
defaultX = 110,
defaultY =80,
offset=-5,
overSrc = "menu/icon-back-2.png",--pressed state image
overX = 110,
overY = 80,
onEvent = buttonhandler,
id = "yourBtnId" -- what you want
}
local function buttonhandler(event)
if event.phase == "release" then
--if you have more buttons handle it whit they id-s
if event.id == "yourBtnId" then
-- when your button was finally released (like in 1st example ended, but this will be called only if the release target is your button)
end
end
end