Jump to content

(pixi.js) how to pass displayObjects from one container to another and gracefully remove the emptied container?


kaydent
 Share

Recommended Posts

when I try to dispose an empty container those previously contained sprites would also get removed, even though it's no longer under the container it looks something like this:
```
  for (let c1i = 0; c1i < c1.children.length; c1i++) {
    const c1s = c1.children[c1i];
    c1s.setParent(c2);
  }
  c1.destroy();
```
what happen is c1.destroy() removes the previously added sprites inside c1,
same thing happens using app.stage.removechild(c1)
thanks
https://codesandbox.io/p/devbox/v8lzq9
here is an example, I was expecting the sprites to not get removed

Link to comment
Share on other sites

  • 2 weeks later...
class Client
{
public:
    Client(std::list<Client> &clients_)
        : thread(&Client::run, this),
          clients(clients_)
    {}

    ~Client()
    {
        thread.join();
    }

    void run()
    {
        // The client does stuff here.

        clients.remove(*this);
    }

private:
    std::thread thread;
    std::list<Client> &clients;
};


int main()
{
    std::list<Client> clients;

    clients.emplace_back(clients);
}

 

https://customproductboxes.com/

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...