Hi, I’ve been Setting a dragging property to a group of objects called shakeableGroup, the drag works but then I wanted to set some limits to the distance that it could be dragged i’ve done different attempts and the dragging property ends up deactivating after the first drag reaches its limits, and it doesn’t let me drag it back, so far my last attempt was:
hasBeenMovedRight = false
– touch listener function
function shakeableGroup:touch( event )
if hasBeenMovedRight == false and shakeableGroup.x <= (display.contentWidth/2) then
if event.phase == “began” then
self.markX = self.x – store x location of object
self.markY = self.y – store y location of object
elseif event.phase == “moved” then
local x = (event.x - event.xStart) + self.markX
local y = (event.y - event.yStart) + self.markY
self.x, self.y = x, y
end
if event.phase == “ended” then
hasBeenMovedRight = true
end
return true
end
if hasBeenMovedRight == true and shakeableGroup.x >= 0 then
if event.phase == “began” then
self.markX = self.x – store x location of object
self.markY = self.y – store y location of object
elseif event.phase == “moved” then
local x = (event.x - event.xStart) + self.markX
local y = (event.y - event.yStart) + self.markY
self.x, self.y = x, y
end
if event.phase == “ended” then
hasBeenMovedRight = false
end
return true
end
end
help is much appreciated