Move all the images using their parent group

So I have 4 rectangles:

local boxGroup = display.newGroup() local box1 = display.newRect(boxGroup,0,0,124,89) box1.x=display.contentCenterX-98 box1.y=display.contentCenterY+110 local box2 = display.newRect(boxGroup,0,0,124,89) box2.x=display.contentCenterX-98 box2.y=display.contentCenterY local box3 = display.newRect(boxGroup,0,0,124,89) box3.x=display.contentCenterX-98 box3.y=display.contentCenterX-30 local box4 = display.newRect(boxGroup,0,0,124,89) box4.x=display.contentCenterX-98 box4.y=display.contentCenterX-140

If I were to move all of them I would have to move each of them individually using buttons like so:

local function moveup() box1.y=box1.y+2 box2.y=box2.y+2 box3.y=box3.y+2 box4.y=box4.y+2 end local button = display.newCircle(display.contentCenterX,display.contentCenterY,30) button:addEventListener("tap",moveup)

However is it possible to move them all together if they were in the same parent group like so:

local function moveup() boxGroup.y=boxGroup.y+2 end local button = display.newCircle(display.contentCenterX,display.contentCenterY,30) button:addEventListener("tap",moveup)

If I cant do that, could I move them if they were all in a table and how would I do it?

Your code should work as posted.

I dont understand this post.

You are asking if the code you wrote work?

Didnt you test it?

I came up with the code at the top of my head and tried it out after posting this thread.

I realised it worked…

lol

manipulating objects through parent display groups is one of the features i love about corona  :smiley:

If you’re using physics for collision detection this will not work as you want it to.

The physics engine (Box2D) and Corona assume all physics objects have the same relative coordinates.  Shifting groups shifts object’s base coordinates for the visible parts, but not the bodies.

Learn something new every day :slight_smile:

Havent used physics yet.

thx

Your code should work as posted.

I dont understand this post.

You are asking if the code you wrote work?

Didnt you test it?

I came up with the code at the top of my head and tried it out after posting this thread.

I realised it worked…

lol

manipulating objects through parent display groups is one of the features i love about corona  :smiley:

If you’re using physics for collision detection this will not work as you want it to.

The physics engine (Box2D) and Corona assume all physics objects have the same relative coordinates.  Shifting groups shifts object’s base coordinates for the visible parts, but not the bodies.

Learn something new every day :slight_smile:

Havent used physics yet.

thx