Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

How to make a layer always to be the highest layer (z-index) ?


weratius
 Share

Recommended Posts

Hello, everybody.

 

I have such a problem:

 

I have two layers:

this.layers = {     profileLayer: game.add.group(),     itemsLayer: game.add.group()};

After clicking a close button I need to destroy the "profileLayer" and hide "itemsLayer"

closeProfile: function() {        closeButton.kill();        myObject.layers.profileLayer.destroy();               //these elements had been added to the "itemsLayer" before        for(var element in itemsObject.items) {
            itemsObject.items[element].cell.visible = false;
            if(itemsObject.items[element].item != null) {
                itemsObject.items[element].item.visible = false;
            }
        }

}

 

Then I need to init them again (I closed profile and I was trying to open it again), so:

       if(!this.itemsAlreadyHasBeenLoadedOnce) {            myObject.layers = {                profileLayer: game.add.group(),                itemsLayer: game.add.group()            }        } else {            myObject.layers.profileLayer = game.add.group();        }

But the "profileLayer" is set higher than itemsLayer (z-index)

 

How can I make itemsLayer to be always the highest layer?

 

Thank you in advance guys. Good luck

 

post-14308-0-25566200-1445075431.png

post-14308-0-84593700-1445075449.png

Link to comment
Share on other sites

Hello,

 

did you try bringToTop?

 

something like this ?

 

here is an error:

Uncaught TypeError: Cannot read property 'parent' of undefined

if(!this.itemsAlreadyHasBeenLoadedOnce) {            myObject.layers = {                profileLayer: game.add.group(),                itemsLayer: game.add.group()            }        } else {            myObject.layers.profileLayer = game.add.group();            myObject.layers.itemsLayer.bringToTop();        }
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...