[Resolved] Rotating a group (display.group dimensions)

Hello,

I have a group with few imageRect objects inside. Trying to rotate it I get the (auto) reference point of TopLeft. Is there a way to set different ones (MiddleCenter, etc)?

Question is, how to get the dimensions of a display.group?

[code]
Shape1 = display.newImageRect( imgDir… “p1_shape1.png”, 123, 77 ); Shape1.x = 504; Shape1.y = 669; Shape1.alpha = 1; Shape1.oldAlpha = 1
myName = display.newImageRect( imgDir… “p1_myname.png”, 153, 16 ); myName.x = 133; myName.y = 337; myName.alpha = 1; myName.oldAlpha = 1

local myGroup = display.newGroup()
myGroup:insert(Shape1); myGroup:insert(myName)

–My issue is in the x and y position for the group. Without this I cannot set the position of the animation
gtStash.myGroup = gtween.new( myGroup, 3, { x = 512, y = 384, rotation = 360, xScale = 1, yScale = 1, alpha=1}, {ease = gtween.easing.linear, repeatCount = math.huge, reflect = false, delay=0, onComplete=""})
[/code] [import]uid: 4883 topic_id: 24138 reply_id: 324138[/import]

To get dimensions you should simply be able to use group.width and group.height :slight_smile: [import]uid: 52491 topic_id: 24138 reply_id: 97512[/import]

Thanks Peach (I am really dumb for not trying that)!

Taking advantage: why myGroup.x always return 0 (instead of the correct position of the group)? Is there a way to get the correct position (x and y) of the group? [import]uid: 4883 topic_id: 24138 reply_id: 97535[/import]

I’d be interested in this also. I had a nightmare trying to reset a “camera” position due to groups seemingly not having their own x and y.

Thanks

Dan [import]uid: 67933 topic_id: 24138 reply_id: 97570[/import]

X actually seems to return fine for me running code below (obviously replace images with your own or use circles);

[lua]local group = display.newGroup()

local test1 = display.newImage(“smile.png”)
local test2 = display.newImage(“smile.png”)
test2.x=100
group:insert(test1)
group:insert(test2)

local function printX ()
print (group.x)
end

transition.to(group, {time=1000, x = 100, onComplete=printX})[/lua]

Can you let me know what is printed for you? If not 100, what version of Corona are you using?

Peach :slight_smile: [import]uid: 52491 topic_id: 24138 reply_id: 97641[/import]

Try with imageRects (who in the hell uses newImage at this moment? :slight_smile: ) and it will only return 0 [import]uid: 4883 topic_id: 24138 reply_id: 97720[/import]

I like newImage :slight_smile:

This code;
[lua]local group = display.newGroup()

local test1 = display.newImageRect(“smile.png”, 32, 32 )
local test2 = display.newImageRect(“smile.png”, 32, 32 )
test1.y, test2.y = 50, 50
test2.x=100
group:insert(test1)
group:insert(test2)

local function printX ()
print (group.x, group.width, group.height)
end

transition.to(group, {time=1000, x = 100, onComplete=printX})[/lua]

Also doesn’t return 0 at any point in the latest stable build.

Are you using a daily build per chance? [import]uid: 52491 topic_id: 24138 reply_id: 98211[/import]

Peach, this is my code:

 -- Layer1 positioning   
 Layer1 = display.newImageRect( imgDir.. "p1\_layer1.png", 1024, 768 );   
 Layer1.x = 512; Layer1.y = 384; Layer1.alpha = 1; Layer1.oldAlpha = 1   
 menuGroup:insert(Layer1); menuGroup.Layer1 = Layer1   
  
 -- shape1eng positioning   
 shape1eng = display.newImageRect( imgDir.. "p1\_shape1eng.png", 219, 66 );   
 shape1eng.x = 164; shape1eng.y = 87; shape1eng.alpha = 1; shape1eng.oldAlpha = 1   
 menuGroup:insert(shape1eng); menuGroup.shape1eng = shape1eng   
  
 -- cube positioning   
 cube = display.newImageRect( imgDir.. "p1\_cube.png", 109, 103 );   
 cube.x = 111; cube.y = 359; cube.alpha = 1; cube.oldAlpha = 1   
 menuGroup:insert(cube); menuGroup.cube = cube   
  
   
 -- External layer properties   
 math.randomseed(os.time())   
  
   
 -- Group(s) creation   
 local gp\_sprite = display.newGroup()   
 gp\_sprite:insert(shape1eng)  
 gp\_sprite:insert(cube)   
   
  
 print(gp\_sprite.x)  

It always return 0 in the print line. I am using build 767 [import]uid: 4883 topic_id: 24138 reply_id: 98370[/import]

gp_sprite is a new group though and it hasn’t been moved, so the x is 0. If you move the group then the x prints correctly. [import]uid: 52491 topic_id: 24138 reply_id: 98432[/import]

I thought it should inherit the position of the boundaries of the objects inside. Seems to be weird because, lets say you animate the group and then wants to send it back to its original position. Setting it to 0,0 will bring it back to the original pos or move it to the screen coordinates 0,0? [import]uid: 4883 topic_id: 24138 reply_id: 98534[/import]

Moving it to 0,0 will put it back to where it was originally :slight_smile: [import]uid: 52491 topic_id: 24138 reply_id: 98697[/import]