Type Number Event touch Revision Release 2022.3683 Keywords touch, xDelta
The x distance in screen coordinates between where the touch event began and its current coordinates.
local object = display.newRect( display.contentCenterX, display.contentCenterY, 100, 100 ) local function move( event ) if ( event.phase == "began" ) then display.getCurrentStage():setFocus( event.target ) event.target.xStart = event.target.x event.target.yStart = event.target.y event.target.isFocus = true elseif ( event.phase == "moved" ) then if ( event.target.isFocus ) then event.target.x = event.target.xStart + event.xDelta event.target.y = event.target.yStart + event.yDelta end else display.getCurrentStage():setFocus( nil ) event.target.isFocus = false end end object:addEventListener( "touch", move )