These are chat archives for pixijs/pixi.js

19th
Oct 2017
Thomas Persson
@thomaspersson
Oct 19 2017 10:37
Hi, seems like sprites does not have a z-Index. On hover I want the sprite to be on top of all other sprites in same container. How can I achieve this?
Ivan Popelyshev
@ivanpopelyshev
Oct 19 2017 11:45
  1. change order of children of the container
  1. use pixi-display
Thomas Persson
@thomaspersson
Oct 19 2017 12:30
@ivanpopelyshev thanks, sounds pretty costly, performance wise to achieve this?
kinda strange that this isn't built in for pixi.
I have created a chart with icons for the different points. When I hover an icon/point I want it to have the highest z-index. So need to be dynamic, and feels very costly todo this on mouse events?
Ivan Popelyshev
@ivanpopelyshev
Oct 19 2017 12:55
there are many ways to make z-indices, and it affects performance, so pixi doesn't have it
pixi-display/pixi-layers has a special optimization that suits many projects
no, it wont be costly on mouse event in this case: the idea is to create two layers, one for everything and second for "on-top" things
move the object into "on-top" and back when you need it
with pixi-layers its just simple asisgnment "obj.parentLayer=topLayer" and "obj.parentLayer=null"
you dont even have to enable sorting :)
Thomas Persson
@thomaspersson
Oct 19 2017 13:04
ah smart one.. this is what I will do, create a new container and clear and place the hovered element! thanks!
Ivan Popelyshev
@ivanpopelyshev
Oct 19 2017 13:05
That's why I've made "display/layers" plugin. You dont have to do "addChild"/"removeChild" with it , and it costs much less than stupid sorting.
It starts affecting performance on 10k elements on slow computers
Thomas Persson
@thomaspersson
Oct 19 2017 13:12
@ivanpopelyshev cool, in my use case I will just write another layer and put the active sprite there, but will definitely check out your library if I need todo more.
Ivan Popelyshev
@ivanpopelyshev
Oct 19 2017 13:32
yep
First you use something basic, then when code complexity grows you start to use the plugin, it covers all those cases. I actually dont know of any plugins for phaser or other engines that can do the same thing, they always start sorting out from beginning and slow everything down.
If "pixi-layers" is slow in some case, it means there are big problems that require much better solution. I have advanced version of it. which handles really collossal amounts of objects, but so far no one except me had to use it.
Thomas Persson
@thomaspersson
Oct 19 2017 14:01
@ivanpopelyshev cool