Distance and boundaries in scaled Groups

I can’t seem to piece everything together. I have a scalable display group with a draggable object within. I can drag the object correctly, but cannot bind it between boundaries. Thus far, any boundaries I make are not consistent between scales.
[lua]local drag = display.newImage(“bird.png”)
localGroup:insert(drag)
drag.x = 50; drag.y = 50

local function draggit( event )
local x, y = localGroup:localToContent( event.x, event.y )
if event.phase == “moved” then
–This is would boundaries would be set
drag.x = x; drag.y = y
end
return true
end[/lua]

Using exact numbers wont work like [lua] if x > 100 then drag.x = 50; end[/lua] nor does [lua]local x0,y0 = localGroup:localToContent( 100, 100 )[/lua]

Then I need the distance between this draggable object and another object. How would I do that? [import]uid: 54716 topic_id: 10763 reply_id: 310763[/import]

Can someone please step in and answer this? The equation is getting longer than expected, rather there should be a much more elegant solution that actually works.

This function thus far is
[lua]local scaleFactor = .5

local wrap = display.newGroup()
wrap.x = 10; wrap.y = -100

local localGroup = display.newGroup()
wrap:insert(localGroup)
localGroup.x = 0; localGroup.y = 0

local drag = display.newImageRect(“bird.png”, 50, 50)
localGroup:insert( drag )

local function draggit( event )
if event.phase == “moved” then
local x1, y1 = localGroup:localToContent( 100, 100 )
local x2, y2 = wrap:localToContent( event.x, event.y )
local eq = x1 * (2 - scaleFactor) + (drag.width * (1-scaleFactor))
if x2 > eq then
x2 = eq
end
end
end
function new()
wrap:scale( scaleFactor, scaleFactor )
return wrap
end[/lua]

It works at a scaleFactor of 1 but becomes visible ‘off’ by .5.
Here my walk through of the function:
1)Grab boundary line via x1.
2)Grab localized event via x2.
3)Scale x1 by (2 - scaleFactor) and add on the drag width if it is scaled.

I am missing one small term… But there should definitely be another way of doing this.

Thanks in advance! [import]uid: 54716 topic_id: 10763 reply_id: 39189[/import]

i am having a similar issue.

When I scale a display group, it scales from the upper-left corner.
When I change its reference point to center, everything inside it goes way off screen (debugging the coordinates doesn’t help either because they are in local coords) and I can’t find them.

Also when I drag something in the scaled group, it gets offset so far that you lose your touch event off it.

Also the boundary checking doesn’t work anymore at greater scales. [import]uid: 63787 topic_id: 10763 reply_id: 40479[/import]