This code works but it is not smooth and didn’t look good…
local rect = display.newRect(150,200,50,50)
local function onTouch(e)
if e.phase == “began” then
rect.markX =rect.x
rect.markY = rect.y
elseif e.phase == “moved” then
local x = (display.contentWidth - e.x - e.xStart) + rect.markX
local y = (display.contentHeight - e.y - e.yStart) + rect.markY
rect.x = x
rect.y = y
elseif e.phase == “ended” then
end
return true
end
Runtime:addEventListener(“touch”,onTouch)