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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -