Update group children position after Group position change

Hi guys,

I am changing a bunch of display objects positions like this.

local myGroup = display.newGroup() local player    --- childrens of myGroup myGroup:insert(player) --------------- later on local distance = 50 transition.to (myGroup, {time = 2000, y = distance + myGroup.y, transition = easing.outQuad}

What happens here, group changes position onScreen but relative y children postion stays the same.

Children changes position onscreen, but they .y is the same!

What I can do here is loop for each child thru transtion.to like this:

for i = 1, myGroup.numChildren do      transition.to (myGroup[i], {time = 2000, y = distance + myGroup[i].y, transition = easing.outQuad} end

Now I change each children relative position, but this method slows my game down!

Do you have any quicker solution (than latest one)?  :smiley:

Many thanks!

Ivan

> Children changes position onscreen, but they .y is the same!

That’s what groups are supposed to do – the children’s coordinates are all relative to the group (or parent).  The children x,y stays the same no matter where the group is moved to.

Depending on what exactly you’re trying to do, maybe you can use obj:localToContent(x,y) and obj:contentToLocal(x,y) from child to parent coordinates as needed.

Thanks jbp1!

> Children changes position onscreen, but they .y is the same!

That’s what groups are supposed to do – the children’s coordinates are all relative to the group (or parent).  The children x,y stays the same no matter where the group is moved to.

Depending on what exactly you’re trying to do, maybe you can use obj:localToContent(x,y) and obj:contentToLocal(x,y) from child to parent coordinates as needed.

Thanks jbp1!