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
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.
Most helpful comment
Its in case he has culling algorithm based on
getBounds(xxx, false). If he usestrueas second param, he can setvisible=falseinstead ofrenderable=false