Jump to content

Sprite.bringToTop() Doesn't do anything.


eldernos
 Share

Recommended Posts

I'm putting together a basic top-down scrolling game and I have three groups of background tiles moving down the screen.  I also have a character I add as a sprite but cannot get it to show up on top.  

 

I've tried bringToTop(), adding it to another group, enabling physics (like the background ones), adding it last, adding it first.  

 

My State object has three groups set at zero z and the sprite at 5 and it still never shows up.  

 

If I don't ever create the other groups, I'm fine.

 

Does it matter that my character is a class derived from Phaser.Sprite instead of just a sprite?  

 

I can't find any reason this is happening.

 

Thanks

Link to comment
Share on other sites

The Display List works in a bottom-up manner. So any Groups or Sprites created first will always appear behind any Groups or Sprites created after them.

 

bringToTop only brings a Sprite to the top of its parent Group - if it has one. For example if you add Group A, B and C (where A is on the bottom, B in the middle and C on the top) and your player is in Group A then calling bringToTop on the player will still make it visually appear behind Groups B and C.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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