Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Slick UI: Destroy or remove element


Recommended Posts

Hi all,

I'm trying to use Slick UI to dynamically create multiple choice question prompts in a new game (see image). The problem is, there doesn't seem to be a way to remove a panel, or update its child elements once they have been created. I couldn't find a way to do this directly through Phaser either. Any help greatly appreciated.

Perhaps there is a Phaser method to destroy all children generated by a particular plugin?




Link to comment
Share on other sites

Thanks for your response, drhayes. This is the code snippet I ended up using as a workaround until I figure out something better:


Where 'n' is the index of the Slick container in game.world.children

Link to comment
Share on other sites

You should save a reference to a UI element or Display Object if you need to modify it later.

The root UI and all the elements have a `container.displayGroup` that is a Phaser.Group and so can call removeAll(). Here's a shortcut:

Phaser.Plugin.SlickUI.prototype.removeAll         =
SlickUI.Element.Button.prototype.removeAll        =
SlickUI.Element.Checkbox.prototype.removeAll      =
SlickUI.Element.DisplayObject.prototype.removeAll =
SlickUI.Element.Panel.prototype.removeAll         =
SlickUI.Element.Slider.prototype.removeAll        =
SlickUI.Element.Text.prototype.removeAll          =
SlickUI.Element.TextField.prototype.removeAll     =
function(destroy, silent, destroyTexture) {
  this.container.displayGroup.removeAll(destroy, silent, destroyTexture);


Link to comment
Share on other sites


  • Recently Browsing   0 members

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