Sign in to follow this  
gamify

remove child of uipanel

Recommended Posts

i am not able to remove 3 buttons inside the popup modal but the popup modal container is removed so i need to remove all its child elements too but removeChild(panel) not woking

panel= new UiContainer(this.pos.x, this.pos.y, 450, 325,"Enter your Feedback","UIPanel");
         panel.addChild(new ButtonUI(
            30, 200,
            "green",
            "Accept",
            "accept_id1",
            UipanelButton
        ));

me.game.world.addChild(panel);

i used below code so only container is removed but not buttons (3 buttons) ,on click of the button inside panel

me.game.world.removeChild(panel);

 

Share this post


Link to post
Share on other sites

ButtonUI = me.GUI_Object.extend({

 onClick : function (/* event */) {

if(this.id == 'close_id3'){

me.game.world.removeChildNow(panel);

}

}

});

Share this post


Link to post
Share on other sites

Looks like this should work: https://github.com/melonjs/melonJS/blob/91e1ca185a21f7d44b871b5542282e14c134e7a5/src/renderable/container.js#L530-L532

Put a breakpoint on me.GUI_Button.onDeactivateEvent and ensure that it is executing when the container is removed. Probably it is not, but you can breakpoint on me.Container.onDeactivateEvent and trace it down the other direction to find out where it's falling over.

Share this post


Link to post
Share on other sites

onDeactivateEvent:function(event){
            $("#label1").remove();
        $("#label2").remove();
         me.game.world.removeChild(panel);
    }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.