Hi,
I have spent enough time trying to figure out a solution to fix x/y positioning mess up when there are nested display groups. Please help. group structure below:
Parent Group
Group 1
Group 2
Issue: When i move group 1, group 2’s x and y automatically changes. Please note Parent group is in transition.
Tried the following:
1. using Containers, this fixes the positioning problem but the graphics is not clean due to the boundary limitations of this feature
-
Changing “anchor points of parent group” based on group 1’s movement, but there are jitters, it doesnt exactly keeps Group 2 in same position. Pseudo code below:
mainclass.lua transition.to (parentgroup, {time = 1000, x = dx, delta = true}) ------------------------------------- gameLoop.lua adjustGroup2Pos () ------------------------------------- initialization.lua function createGroup() parentGroup.anchorChildren = true parentGroup.anchorX = 0.5 parentGroup.anchorY = 0.5 parentGroup:insert (group 1) parentGroup:insert (group 2) globalVars.dummyblock = display.newImageRect (“border.png”, 10, 10) globalVars.dummyblock.x = parentGroup.x globalVars.dummyblock.y = parentGroup.y parentGroup:insert (globalVars.dummystone) end -------------------------------------------------------- function adjustGroup2Pos() dummyblockX, dummyblockY = globalVars.dummyblock:localToContent(0,0) deltaX = dummyblockX - parentGroup.x deltaY = dummyblockY - parentGroup.y parentGroup.anchorX = parentGroup.anchorX + (deltaX / parentGroup.height) parentGroup.anchorY = parentGroup.anchorY + (deltaY / parentGroup.height) end -----------------------------------------------------
Thanks very much,