Pixi.js: best way for renderable childrens and other obj

Created on 25 Jan 2018  路  9Comments  路  Source: pixijs/pixi.js

Suppose a parent Obj is rendered.
the parent has 4 other sprites. (childrens)
For example, i want to make visible only sprites 2.
What is more efficient in terms of performance for disables all other sprites childs, (0,1,3)

is ?
1: .renderable = false; //for all other sprites
2: .visible = false; // for all other sprites
3: remove childs and keep only the rendered child;

am try understand the update in deep
thank

Most helpful comment

Its in case he has culling algorithm based on getBounds(xxx, false). If he uses true as second param, he can set visible=false instead of renderable=false

All 9 comments

Setting visible to false is quicker than renderable false, as it won't call updateTransform.
I wouldn't remove / add children dynamically. Looping over an array checking a boolean value is going to be lighting quick. Manipulating an array... more effort, and asking for trouble imo.

Now, is your example was with hundreds/thousands of children, and it wasn't a regular changing of visibility, I'd do some benchmarking to find out if having less children helps. But for most situations, just set visibility to false

1st option.

Why Ivan? The docs make it out that visibility false cuts out more work than renderable false.

Its in case he has culling algorithm based on getBounds(xxx, false). If he uses true as second param, he can set visible=false instead of renderable=false

in fact, my reasoning was mostly touch the
PIXI.extras.AnimatedSprite.prototype.update
because use the updateTexture.
In fact, i was experiment a small change, but I wondered if the fact that I'm doing the .Renderable = false are better than a remove child, for the global update.

    PIXI.extras.AnimatedSprite.prototype.updateTexture = function updateTexture() {
        this._texture = this._textures[this.currentFrame];
        this._textureID = -1;
        if (this.renderable && this.onFrameChange) { //+ this.renderable fix overleay callback memory fast call
            var ran = Math.random() * 99;
            var len = this._motionContexts.length; // how many context to pass chek
            this.onFrameChange(this.currentFrame, ran, len); //+ pass frame context + ran
        }
    };

is it better to remove all childrens if not need or keep them but in, renderable = false;

getBounds(xxx, false) ??? getBounds (skipUpdate, rect)
http://pixijs.download/dev/docs/PIXI.DisplayObject.html#getBounds
am not understand sorry

I'm talking about first param :)

ok ok
hey thank i lot this solved

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

distinctdan picture distinctdan  路  3Comments

sntiagomoreno picture sntiagomoreno  路  3Comments

MRVDH picture MRVDH  路  3Comments

madroneropaulo picture madroneropaulo  路  3Comments

lucap86 picture lucap86  路  3Comments