Jump to content

Destroying Containers error


HugoLuc
 Share

Recommended Posts

Hi Guys, I'm running into this error message while trying to destroy an sprite or container:

56e0a256369a1_ScreenShot2016-03-09at16.4

I Run into this problem even when destroying a simple bg image:

    function Round(){

        this.score = 0;
        this.language = "english"
        this.background = PIXI.Sprite.fromImage('sprites/backGrounds/BackGround-01.png');        
        stage.addChild(this.background);
    }

//LATER 

    Round.prototype.destroy = function(){
        
        this.background.destroy()


    }

 

I have no idea what I'm doing wrong =/

Is there a specific way to destroy objects?

Can anyone help?

Link to comment
Share on other sites

Interesting. What's the difference between removing and destroying then? 

That's a good question. I want to switch from one game to the other inside the website. The games use different textures from each other, so I thought that destroying the containers with their textures would free up some memory. What would be the best practice in this case?   

Thanks! 

Link to comment
Share on other sites

So if I have a bunch of texture inside the container I should call sprite.destroy() in all sprites individually?
If I do "container.destroy(true)" wouldn't that destroy every element inside the container ( including the sprites and textures)?

Btw, thank you! I'm new to pixi and I love it! This forum have been very helpful too! People reply really fast! =)
 

Link to comment
Share on other sites

Yeah, that's a problem: sprites inside container wont be called with (true, true) and textures wont be freed. Also you can find your textures in loader.resources (if you use it) or in PIXI.Texture.TextureCache, and call something like

PIXI.utils.TextureCache["mystuff.png"].destroy(true);

Thank you too! I hope to change that behaviour in v4, its not obvious now.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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