Search the Community
Showing results for tags 'zindex'.
Found 3 results
Hello! First of all, as this is my first post and all, I would like to congratulate Mat and the team working on pixi.js. A few days ago I was looking for a nice and fast 2D game engine and I found yours here. I found it quite easy to understand and to implement, though at some times a bit daunting due to cross-version examples. However, I was able to start off a hobby project of mine quite fast. Speaking of which, I started an isometric map editor, you may see a very alpha (and buggy) version of it here. All is going well, but I am having a question regarding the following situation: The editor is meant to construct an isometric map by adding/moving around tiles. Each tile would have two sets of coordinates: - isometric x, y, z that would position each tile within the game's world-space. - regular x, y to be used for view-port rendering that get translated from the isometric coordinates. The problem I need to resolve now is the order of rendering the tiles. Obviously, tiles closer to the camera would obstruct the tiles further back, so I thought to set up a rendering order calculated from the isometric x, y coordinates, considering the farthest point as the x, y origin: var orderID = isometric.x + isometric.y * width The ID's produced this way are exemplified by the attached image. In theory, if I would be able to render the children based on the order of those ID's, the problem would be solved, and that would elegantly also resolve the problem of rendering a moving character the correct way in order to realistically show up behind or in front of columns, trees or other elements. A good solution for this would be the one proposed by tengotengo here. He suggests sorting the children array each time you make a modification to it. This solution would work great in the editor, but I was wondering if the sorting is by any chance too taxing for a game-play? I expect at some moments to have at least 20 players in the same room + several moving NPC's. Sorting and re-sorting the whole array each time one of them makes a move seems like a bad idea. So, I was wondering, would there be a better way of only moving up/down in the array the "dynamic" children?