A question about how an app is viewed.

Hello, very new user here with a question that I assume has a basic answer, but for the life of me can’t figure out.

A group of students, including myself, is making a game with corona as a project, and we have come across a problem we seem to be stuck on. We would be incredibly greatful for any light that could be shed on the subject.

We are trying to design our HUD to be this:

      On the left side of the screen, a grid of tiles, and on the right, a menu. Pretty standard layout for an App Game. However, we are making our own objects, these panels, which would have several different values associated with them, numerical booleans for verifying construction, etc, and these panels would be connected, in a checkboard/chess-like layout. We want it to be work in such a way that when a player clicks and drags a tile, it drags the whole board around, while the menu on the right side of the screen stays in place. We were thinking this could be achieved with displayGroups, but we are somewhat lost. Any suggestions on how to move all of these objects at the same time? Or is there a more efficient way we should be going about this? -Thanks in advance for any suggestions.

displayGroups are definitely the way to go. The trick is that they are simple tree hierarchies.

  1. The root in this case should be the storyboard scene.

  2. The two major branches should then be your UI and then the board.

    function scene:createScene(event) local scene = self.view – the root local uiGroup = display.newGroup() – for UI objects – insert objects using uiGroup:insert(objectname) local boardGroup = display.newGroup() – for board objects – insert objects using boardGroup:insert(objectname) – Once you have at least one object in each group, insert the branches into the scene scene:insert(uiGroup) scene:insert(boardGroup) end

This way, you can move the entire boardGroup at once and it won’t affect the uiGroup. Just make sure to attach your touch listeners to the group (boardGroup) and not the tiles. (There are ways around that, though)

  1. The other trick to remember is that displayObjects can only be in one displayGroup at a time. (So having one group nested inside another, nested inside another, etc. is fine, but there can only be one at each level.)

So you can manipulate this; if you have something in uiGroup and suddenly you want to move it with the board, just make sure to add boardGroup:insert(theobjectyouwanttomove) first!

Ah, You are wonderful :smiley: Thanks a bunch.

displayGroups are definitely the way to go. The trick is that they are simple tree hierarchies.

  1. The root in this case should be the storyboard scene.

  2. The two major branches should then be your UI and then the board.

    function scene:createScene(event) local scene = self.view – the root local uiGroup = display.newGroup() – for UI objects – insert objects using uiGroup:insert(objectname) local boardGroup = display.newGroup() – for board objects – insert objects using boardGroup:insert(objectname) – Once you have at least one object in each group, insert the branches into the scene scene:insert(uiGroup) scene:insert(boardGroup) end

This way, you can move the entire boardGroup at once and it won’t affect the uiGroup. Just make sure to attach your touch listeners to the group (boardGroup) and not the tiles. (There are ways around that, though)

  1. The other trick to remember is that displayObjects can only be in one displayGroup at a time. (So having one group nested inside another, nested inside another, etc. is fine, but there can only be one at each level.)

So you can manipulate this; if you have something in uiGroup and suddenly you want to move it with the board, just make sure to add boardGroup:insert(theobjectyouwanttomove) first!

Ah, You are wonderful :smiley: Thanks a bunch.