Placing an object on FRONT all the time....

hello…

I have a brackground, and 3 circles/objects.

all of them are in a group.

I can move them really nice.

But I add an extra image/circle.

like a button.

This button has to be ON FRONT all the time

but I can not do that.

All of the objects are inserted in the …    local sceneGroup = self.view

for composer

and only the “button” is outside the newGroup that I made.

I guess that’s why is in the back.

I tried different ways and I just can not have that object on front

botoncito = display.newCircle(sceneGroup, 0, 0, 50 ) – BLUE
botoncito:setFillColor(.6, .5, 1)
botoncito.x = display.contentCenterX
botoncito.y = display.contentHeight - 100
botoncito:toFront()


QUESTION


How can I have an object always on front, regardless the group they are in?

Thanks you for your time

Hi there,

One solution is to keep your background items in a separate group.  For instance:

--Create a group to hold all the background objects local backGroup = display.newGroup() --Create object 1 and add it to the background group local circle1 = display.newCircle(...) backGroup:insert(circle1) --Create object 2 and add it to the background group local circle2 = display.newCircle(...) backGroup:insert(circle2) --Add background group to the main scene sceneGroup:insert(backGroup) --Now create your button local button = display.newCircle(...) --Add it to the scene sceneGroup:insert(button) --Now, whatever happens to the objects in the background group, your button will always --be on top.

Your button will remain on top of anything in the background group because it was added to the scene after the background group.  Any new objects created and added to the background group will stay in the background as well.

Thank you very much, this works GREAT!!!

Victor

Hi there,

One solution is to keep your background items in a separate group.  For instance:

--Create a group to hold all the background objects local backGroup = display.newGroup() --Create object 1 and add it to the background group local circle1 = display.newCircle(...) backGroup:insert(circle1) --Create object 2 and add it to the background group local circle2 = display.newCircle(...) backGroup:insert(circle2) --Add background group to the main scene sceneGroup:insert(backGroup) --Now create your button local button = display.newCircle(...) --Add it to the scene sceneGroup:insert(button) --Now, whatever happens to the objects in the background group, your button will always --be on top.

Your button will remain on top of anything in the background group because it was added to the scene after the background group.  Any new objects created and added to the background group will stay in the background as well.

Thank you very much, this works GREAT!!!

Victor