I’m trying to constrain the drag movement between the screen boundaries but If you move fast enough it goes past the 50 and 200 limits
If you move fast enough it goes past the 50 and 200 limits local r = display.newRect(100,100,30,30) r:addEventListener("touch",function(event) if event.phase == "began" then display.getCurrentStage():setFocus(event.target) event.target.ox = event.target.x end if event.phase == "moved" and ((event.xStart \< event.x and event.target.x \< 200) or (event.xStart \> event.x and event.target.x \> 50)) then event.target.x = event.x - event.xStart + event.target.ox + 1 end if event.phase == "ended" or event.phase == "cancelled" then display.getCurrentStage():setFocus(nil) end end)
Anyone had this problem before? Is there a solution for this problem?
Thank you