libgdx - Reusable scene2d dialog -


a typical usecase scene2d modal dialog have 2 buttons in it, 1 user action confirmation , 1 cancel.

simply clicking cancel button results in closing (hiding) dialog window (which default behaviour , needed, since don't want happen), repeating action supposed show again (ex. clicking "delete" button show delete confirmation dialog) results in nothing happening (because dialog hidden).

what proper way enable dialog back?

should show() called in no button listener?

nobutton.addlistener(new clicklistener() {                 @override                 public void clicked(inputevent event, float x, float y) {                     deletedialog.show(stage);                 }; 

the official scene2d code example creates new dialog each time, understanding it's better reuse such elements.

you have dialog in variable guess:

group dialog = new group(); 

you add this:

stage.addactor(dialog); 

listener remove - remove method doesn't delete anything, removes actor stage:

nobutton.addlistener(new clicklistener() {     @override     public void clicked(inputevent event, float x, float y) {         dialog.remove();     };   

and when want display again:

stage.addactor(dialog); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -