event.phase

Type String
Event touch
Revision 2017.3060
Keywords touch, phase

Overview

A string identifying where in the touch sequence the event occurred. Can be one of the following values:

Example

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 )