Fovi Posted May 19, 2017 Share Posted May 19, 2017 Hi, i wondering what is correct way to remove container ? Is it enough to call destroy function on container, or do i need to remove each sprite first. And what about removing container from root stage ? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 20, 2017 Share Posted May 20, 2017 correct way is IKnowParentContainer.removeChild(thisSmallThingy); but sometimes you dont remember where did you put it! myContainer.parent.removeChild(myContainer); and sometimes you know that it wont be used anymore AT ALL. Then if all Text and Sprites elements doesnt have textures that you will use in future, you can destroy all textures inside myContainer.parent.removeChild(myContainer); myContainer.destroy({children:true, texture:true, baseTexture:true}); But dont worry. If you dont destroy things, javascript gc and our own pixi gc will take care of that in a few minutes. The only evil thing is generated textures, its better if you destroy renderTextures you created. If you dont know whats a renderTexture, dont worry pxlatedtraveler and chriscauley 1 1 Quote Link to comment Share on other sites More sharing options...
dmko Posted May 22, 2017 Share Posted May 22, 2017 On 5/20/2017 at 8:37 PM, ivan.popelyshev said: our own pixi gc will take care of that in a few minutes. Can you explain this a bit more? Will PIXI automatically destroy(false) unreachable DisplayObjects and/or destroy(true) unreachable Textures? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 23, 2017 Share Posted May 23, 2017 DisplayObjects are taken by javascript GC. Textures that weren't used for 2-3 minutes or so, will be collected by pixi GC which is turned on by default. You can turn it off if it gives you lags. But if you dont destroy BaseTexture's , images will still live in "PIXI.utils.TextureCache", but they will be in png form (browser optimizes that), which is small compared to fully loaded texture pxlatedtraveler 1 Quote Link to comment Share on other sites More sharing options...
canvasman Posted December 25, 2018 Share Posted December 25, 2018 Looks like when sprite.destroy() is used, it removes the sprite from parent container. Before destroying sprite, should I still remove it first? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 25, 2018 Share Posted December 25, 2018 You don't need to destroy sprites, its not required, pixi does not cache them. All pixi objects can be collected by default javascript GC, except those which hold links to WebGL or cached things. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.