Getting X/Y from in group?

Hello,

Someone helped me in the past here by showing me how to create a group that I can move everything around at once with the touch event. So now I am dragging an object over the group and want to insert it where I stop at. I know how to insert an object into a group. But when I’m done dragging I cannot tell what the x/y is right there.

How can I determine this for a layer that I can pan around and also zoom in/out? When I move the object it is the x/y position of the screen. When it is over the layers.content I want to know the x/y at any time. How do I calculate the offset that includes the scaling as well?

Thanks,

Warren

local layers = display.newGroup() layers.container = display.newContainer( layers, 320, 300 ) layers.container.anchorX = 0 layers.container.anchorY = 0 layers.container.anchorChildren = false layers.container.x = 100 layers.content = display.newGroup() layers.overlay = display.newGroup() layers:insert(layers.container) layers:insert(layers.overlay) layers.container:insert(layers.content)

Groups by default have their origin at 0, 0.  group.x and group.y should return you 0 and 0 if you’ve not moved the group.

Rob

So if I do move the group how do I get the offset of the group? With layers.content.x and layers.content.y?

Look at:

https://docs.coronalabs.com/api/type/DisplayObject/localToContent.html

and

https://docs.coronalabs.com/api/type/DisplayObject/contentToLocal.html

Groups by default have their origin at 0, 0.  group.x and group.y should return you 0 and 0 if you’ve not moved the group.

Rob

So if I do move the group how do I get the offset of the group? With layers.content.x and layers.content.y?

Look at:

https://docs.coronalabs.com/api/type/DisplayObject/localToContent.html

and

https://docs.coronalabs.com/api/type/DisplayObject/contentToLocal.html