java - LIBGDX making 5 different buttons on one screen -


i have 5 buttons need make different things don't , need know how make them it.

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; }  public void create () {     stage = new stage(); }  @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();      stage.setviewport(854, 480, true);     stage.getcamera().translate(-stage.getgutterwidth(), -stage.getgutterheight(), 0);      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.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.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.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.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.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);      /**      * 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(); }  public void playbutton(button play) {  } } 

so 5 buttons set , there actions , listeners not , when single 1 button out test works button can clicked on screen think issue button areas not know how set up.

i have tryed .getheight(), .getwidth etc. still same. although in texture atlas height , width images same makes 1 image issue ?

for first problem, buttons doesn't anything, think it's because event propagated of buttons, in order have been added stage. problem touchdown() method returns true. means propagation should stop , touchdown() method of others actors doesn't called. feel nothing in fact something, it's touchdown() method empty.

for second problem, it's because didn't set size of actors.


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 -

CSS3 Transition to highlight new elements created in JQuery -