Two questions regarding display groups.

Hi,

I have two questions regarding working with Display Groups, as follows:

1- I’ve read documentation of Display Groups at this link which indicates that “Groups are created with a default reference point of TopLeftReferencePoint, where most other Display Objects are created with
CenterReferencePoint.”

But when I made one display group and added a new sprite to it and didn’t position it manually, it was not positioned to the top left corner of the screen and I had to manually call set setReferencePoint on the display group.

What am I missing?

2- How can I retrieve objects that I “insert” into a display group? I created some sprites and “insert”-ed them into my display group but later on I want to access them and set animation sequence on them but I don’t know how to access items that I put in a display group via insert method.

Thanks!

Without setting any x,y coords or referencePoints, and inserting a picture into a group:

  • The group.x,y == 0,0 top left of screen (top left of group is at 0,0)

  • The image.x,y == 0,0 Centerpoint of image

So the image will display it’s lower right quadrant onscreen (since 0,0 is the image’s centerpoint, placed at 0,0 in the group, which is top left of the screen).

Regarding retrieving objects in a group, I just make a variable in the group for it… As in:

[lua]

   local  lifeIndicator = display.newImage(“lifeIndicator.png”)

   group:insert(lifeIndicator)

   group.lifeIndicator = lifeIndicator

[/lua]

Then, you can access it later however you like.

Thans mpappas,

1- Thanks for the descriptive reply.

2- I actually did this before posting this topic, thought maybe there is a way without assigning a variable in the group.

Without setting any x,y coords or referencePoints, and inserting a picture into a group:

  • The group.x,y == 0,0 top left of screen (top left of group is at 0,0)

  • The image.x,y == 0,0 Centerpoint of image

So the image will display it’s lower right quadrant onscreen (since 0,0 is the image’s centerpoint, placed at 0,0 in the group, which is top left of the screen).

Regarding retrieving objects in a group, I just make a variable in the group for it… As in:

[lua]

   local  lifeIndicator = display.newImage(“lifeIndicator.png”)

   group:insert(lifeIndicator)

   group.lifeIndicator = lifeIndicator

[/lua]

Then, you can access it later however you like.

Thans mpappas,

1- Thanks for the descriptive reply.

2- I actually did this before posting this topic, thought maybe there is a way without assigning a variable in the group.