How to get touch location in Corona ?

By | August 21, 2011

Hi,

For getting touch location in Corona, use the following code,


--Your touch event listener
 local function myTouchListener( event )
        if event.phase == "began" then
        --Touch coordinates can be accessed by event.x/event.y properties of touch event
            print( "Touched!" )
            print ("Touch X = #"..event.x)
            print ("Touch Y = #"..event.y)
        end
    end

--Adding an event listener for touch
Runtime:addEventListener( "touch", myTouchListener )

Leave a Reply

Your email address will not be published. Required fields are marked *