Type String Event touch Revision Release 2025.3721 Keywords touch, phase
A string identifying where in the touch sequence the event occurred. Can be one of the following values:
"began" — indicates that a touch has started on the screen."moved" — indicates that a touch has moved on the screen."ended" — indicates that a touch has been lifted from the screen."cancelled" — indicates that the system cancelled tracking of the touch (not to be confused with "ended").local object = display.newImage( "ball.png" )
function object:touch( event )
if event.phase == "began" then
display.getCurrentStage():setFocus( self )
self.isFocus = true
elseif self.isFocus then
if event.phase == "moved" then
print( "moved phase" )
elseif event.phase == "ended" or event.phase == "cancelled" then
display.getCurrentStage():setFocus( nil )
self.isFocus = false
end
end
return true
end
object:addEventListener( "touch", object )