java - LIBGDX background for main menu is showing up white -


my background image not showing up, shows white square in corner this.

https://dl.dropboxusercontent.com/u/45938379/menu.png

i need know how fix this, actors showing behind can see.

here code

public class mainmenu implements screen {  crazyzombies game; stage stage; textureatlas atlas; skin skin; spritebatch batch; button play, option, quit, custom, store;  textureregion background;  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);      batch.begin();     stage.draw();     drawbackground();     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.setx(gdx.graphics.getwidth() / 2 - quit.getwidth() / 2);     quit.sety(gdx.graphics.getheight() / 2 - quit.getheight() / 2);      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.setx(gdx.graphics.getwidth() / 2 - store.getwidth() / 2);     store.sety(gdx.graphics.getheight() / 2 - store.getheight() / 2);      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.setx(gdx.graphics.getwidth() / 2 - custom.getwidth() / 2);     custom.sety(gdx.graphics.getheight() / 2 - custom.getheight() / 2);      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);     custom.setx(gdx.graphics.getwidth() / 2 - custom.getwidth() / 2);     custom.sety(gdx.graphics.getheight() / 2 - custom.getheight() / 2);      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.setx(gdx.graphics.getwidth() / 2 - play.getwidth() / 2);     play.sety(gdx.graphics.getheight() / 2 - play.getheight() / 2);      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) {             game.setscreen(new gamescreen(game));         }     });      /**      * end play button      */     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);      background = atlas.findregion("background");     background.getregionheight();     background.getregionwidth(); }  public void drawbackground() {     float w = 854;     float h = 480;     float y = 0;     float x = 0;     batch.draw(background, x, y, w, h); }  @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(); } 

}

what have noticed if rid of

stage.draw(); 

the image shows up.

take out stage.draw() out of batch.begin() , batch.end(). stage have it's own spritebatchso have concurenting ones @ moment. think cause troubles. best way this:

@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();         drawbackground();         batch.end();     } 

i recommend put background inside stage. image actor can add stage , call .toback() (back) have in background.
libgdx image


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 -