对象没有向相反方向拖动
local rect = display.newRect(150,200,50,50)
本地函数onTouch(e) 如果e.phase ==“开始”则
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
结束
运行时:addEventListener(“ touch”,onTouch)
它沿相反方向拖动,但不平滑