Is there any "gotcha"'s while using display groups?

Hi,

For my HUD, I wanted to make a display group, but the I faced with a bug or something I did not understand.

As I’ve read read about the display groups, their default origin is TopLeft corner, as opposed to normal display groups and their default center origin.

What I want to achieve is have a display group placed on my top left corner of screen and then offset my objects that are inserted into that group accordingly but then I faced this but that I made this topic for.

First of all, this is my code:

function M.new(xPos, yPos) local HUDcontiner = display.newGroup() -- It has to be a display object in order to register for events HUDcontiner.x, HUDcontiner.y = 0, 0 local temp = display.newImageRect("hud\_background.png", 320, 113) temp:setReferencePoint(display.TopLeftReferencePoint) -- temp.x = 0 -- temp.y = 0 HUDcontiner:insert(temp) return HUDcontiner end

And my questions are:

1- I explicitly set the origin of background file, the “temp” variable, to top left corner so why when I run this code, the background image file, hud_background, is not placed on top left corner of screen and it’s center is on top left corner of display group?

2- Please note the like that is “temp.x = 0”. If I comment this line out, then the background image’s center will be placed on where I tell it to be, in another word, it’s origin will be the center, not top left. But when I place that “temp.x = 0” code, it seems that it obeys that setReferencePoint and go where it should.

So if I pass zero to it, changed reference point will take effect, if not, it will stay at where it was.

It’s somewhat logical but I think it may or should that when you change reference point, it’s position should change instantly. Maybe it’s not the case with Corona or I missed something here.

Thanks.