Tempus35 Posted July 13, 2015 Share Posted July 13, 2015 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 More sharing options...
stupot Posted July 15, 2015 Share Posted July 15, 2015 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 More sharing options...
Tempus35 Posted July 20, 2015 Author Share Posted July 20, 2015 Yes and I did try that out, I had to adjust some things but it is working as I need now. Thanks for reaffirming that I was doing it right. Link to comment Share on other sites More sharing options...
Recommended Posts