Jump to content

Group sorting / ordering?


joshrmt
 Share

Recommended Posts

This is probably been asked before, but I haven't found any great answers yet.  I need the sprites in my game drawn based on their y position.  It's a top-down RPG, so sprites need to be drawn on the screen from top to bottom to properly overlap/occlude each other.  Are there any provisions for this as part of the Phaser groups?

 

Currently I am having to re-sort the entire sprite list anytime something moves.  I saw a few fields within Group that hint at the feature I need, but they don't seem to be working.

 

Thanks!

Link to comment
Share on other sites

Yes we used to support this, it was trivial to do when the render list was an array, but when Pixi.js moved to a doubly linked list internally it made sorting like this significantly more complex and time consuming, and we've not yet found a decent (fast) way to handle it. This is a quite common question on the Pixi forum too, so maybe something will come of it.

Link to comment
Share on other sites

I would imagine that the children need to be stored in a specific order and then an optimal search algorithm to perform the minimum number of iterations (swaps) on the children.  I don't know much about this sort of thing though.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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