java - LIBGDX having more than 1 button on the main menu -


i have 5 buttons want put on main menu when have 5 actors doesn't work , when take them out , leave 1 in works.

how around having multiple buttons?

here code

public class mainmenu implements screen {  crazyzombies game; stage stage; textureatlas atlas; skin skin; spritebatch batch; button play, option, quit, custom, store, menu;  public mainmenu(crazyzombies game) {     this.game = game; }  @override public void render(float delta) {     gdx.gl.glclearcolor(0.09f, 0.28f, 0.2f, 1);     gdx.gl.glclear(gl10.gl_color_buffer_bit);      stage.act(delta);     stage.draw();      batch.begin();     batch.end(); }  @override public void resize(int width, int height) {     if (stage == null)         stage = new stage(width, height, true);     stage.clear();      gdx.input.setinputprocessor(stage);       /**      * quit button      */      textbuttonstyle stylequit = new textbuttonstyle();     stylequit.up = skin.getdrawable("8layer");     stylequit.down = skin.getdrawable("8layer");      quit = new button(stylequit);     quit.setwidth(854);     quit.setheight(480);      quit.addlistener(new inputlistener() {         public boolean touchdown(inputevent event, float x, float y,                 int pointer, int button) {             return true;         }          public void touchup(inputevent event, float x, float y,                 int pointer, int button) {          }     });      /**      * end quit button      */       /**       * store button       */      textbuttonstyle stylestore = new textbuttonstyle();     stylestore.up = skin.getdrawable("9layer");     stylestore.down = skin.getdrawable("9layer");      store = new button(stylestore);     store.setwidth(854);     store.setheight(480);      store.addlistener(new inputlistener() {         public boolean touchdown(inputevent event, float x, float y,                 int pointer, int button) {             return true;         }          public void touchup(inputevent event, float x, float y,                 int pointer, int button) {             game.setscreen(new storescreen(game));         }     });      /**      * end store button      */       /**       * customs button       */      textbuttonstyle stylecustom = new textbuttonstyle();     stylecustom.up = skin.getdrawable("10layer");     stylecustom.down = skin.getdrawable("10layer");      custom = new button(stylecustom);     custom.setwidth(854);     custom.setheight(480);      custom.addlistener(new inputlistener() {         public boolean touchdown(inputevent event, float x, float y,                 int pointer, int button) {             return true;         }          public void touchup(inputevent event, float x, float y,                 int pointer, int button) {             game.setscreen(new customscreen(game));         }     });      /**      * end customs button      */       /**       * options button       */      textbuttonstyle styleoptions = new textbuttonstyle();     styleoptions.up = skin.getdrawable("11layer");     styleoptions.down = skin.getdrawable("11layer");      option = new button(styleoptions);     option.setwidth(854);     option.setheight(480);      option.addlistener(new inputlistener() {         public boolean touchdown(inputevent event, float x, float y,                 int pointer, int button) {             return true;         }          public void touchup(inputevent event, float x, float y,                 int pointer, int button) {             game.setscreen(new optionscreen(game));         }     });      /**      * end options button      */       /**       * play button       */      textbuttonstyle styleplay = new textbuttonstyle();     styleplay.up = skin.getdrawable("7layer");     styleplay.down = skin.getdrawable("7layer");      play = new button(styleplay);     play.setwidth(854);     play.setheight(480);      play.addlistener(new inputlistener(){      });      play.addlistener(new inputlistener() {         public boolean touchdown(inputevent event, float x, float y,                 int pointer, int button) {             return true;         }          public void touchup(inputevent event, float x, float y,                 int pointer, int button) {             gdx.app.log(crazyzombies.log, "un-touched");             game.setscreen(new gamescreen(game));         }     });      /**      * end play button      */      /**      * start background      */      textbuttonstyle stylemenu = new textbuttonstyle();     stylemenu.up = skin.getdrawable("background");      menu = new button(stylemenu);     menu.setwidth(854);     menu.setheight(480);      /**      * end background      */      //stage.addactor(menu);     stage.addactor(play);     //stage.addactor(option);     //stage.addactor(store);     //stage.addactor(custom);     //stage.addactor(quit);  }  @override public void show() {     audio.playmusic(true);     batch = new spritebatch();     atlas = new textureatlas("data/mainmenu/mainmenu.pack");     skin = new skin();     skin.addregions(atlas); }  @override public void hide() {     dispose(); }  @override public void pause() {  }  @override public void resume() {  }  @override public void dispose() {     batch.dispose();     skin.dispose();     atlas.dispose();     stage.dispose();     audio.dispose(); } 

}

  1. create table object.
  2. add buttons it.
  3. add table object stage.

hope helps. luck.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -