IH121

remove_child doesn't remove Object

Recommended Posts

the line:


            if(user_cubes[i][0]!==undefined){
                console.log("remove_cubes -> user_cubes[i][0] !== undefined");
                console.log(user_cubes[i][0]);
                app.stage.removeChild(user_cubes[i][0]);
            }

prints:

remove_cubes -> user_cubes[0] !== undefined

and the next object:

e {_events: n, _eventsCount: 0, tempDisplayObjectParent: null, transform: e, alpha: 1, …}

which is seems tobe a pixi object, and when written in console the object is deleted.

i don't expect to get a solution, considering this is just a sample from the long code, but if one of you has an idea what the problem can be it could help a lot.

Share this post


Link to post
Share on other sites

Hello, and

Welcome to the forums!

My answer will be very short: what do you expect here? that console shows null? That object will be empty? "removeChild" just removes this particular container from another container childs list, and maybe modifies a few variables related to that.

If you want clear object fields, call destroy() on it, it will also call removeChild. If you want to get rid of object from javascript memory, well, you have to read have JS GC works, that's a bigger topic.

Edited by ivan.popelyshev

Share this post


Link to post
Share on other sites
5 minutes ago, ivan.popelyshev said:

Hello, and

Welcome to the forums!

My answer will be very short: what do you expect here? that console shows null? That object will be empty? "removeChild" just removes this particular container from another container childs list, and maybe modifies a few variables related to that.

If you want clear object fields, call destroy() on it, it will also call removeChild. If you want to get rid of object from javascript memory, well, you have to read have JS GC works, that's a bigger topic.

I expected the visual propety to be deleted, removed from the stage.

the cube object exist on the board and when I normally use this command it works fine.

later in the code I discard the object and I let the garbage collector "do it's thing":

user_cubes[i].pop();
user_cubes[i].pop();

and thanks for the nice greeting into the forums, I am glad to have a place to consult about my PIXI development problems

Edited by IH121

Share this post


Link to post
Share on other sites
5 minutes ago, ivan.popelyshev said:

I expected the visual propety to be deleted, removed from the stage.

Sorry, I dont understand you. Is it visible on screen? Are you sure its child of stage and not a grandchild?

yes it's visable on the screen, and I am sure it's not the grandchild becuase I was able to remove it using the chrome console.

Share this post


Link to post
Share on other sites

It should work, I have no idea what is wrong there.

Place a breakpoint  in that place and see if removeChild affects children array.

If you are too tired to debug , then reduce a demo to minimal lines of code and post it on codepen/jsfiddle/pixi-playground.

Edited by ivan.popelyshev

Share this post


Link to post
Share on other sites
37 minutes ago, ivan.popelyshev said:

It should work, I have no idea what is wrong there.

Place a breakpoint  in that place and see if removeChild affects children array.

If you are too tired to debug , then reduce a demo to minimal lines of code and post it on codepen/jsfiddle/pixi-playground.

I'll try to to reduce the number of lines, I never quite captured the idea of the chrome debugger. but before I do, your suggestion gave me an idea, I might try to examine the stage property.

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.