Jump to content

Question regarding z-layers


Tempus35
 Share

Recommended Posts

Hello, so I am making a simple whack the mole style game and I have a question about z layers. So the back row of moles has to be behind the middle row and behind the bg/grid layer they come out of. I know sprites render based on the order they are added to the scene. So the solution I thought of was to group each row of moles then take the background/grid image and break it into 3 layers. I would then render the back row of moles, then the first bg layer, then middle moles, then second bg layer etc. Seems tedious etc.

 

I am just wondering if there is a simpler method to do what I am trying to do.

Link to comment
Share on other sites

Yes, the game objects are rendered in the order they are added, with the 1st added being at the back and the last added being on top.  The z-index is a read only property, setting it will not alter the render order, there are other ways to move items about to affect their z-index.

 

What you have suggested seems entirely appropriate, add all the back row of moles first then a slice of the bg, then the middle row and then another slice of the bg, etc.

 

I'm assuming that your description of breaking the bg up is because each row of moles has something partially obscuring it that a nearer row needs to be in front of this.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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