android - Where to draw in libGDX -


i made game in libgdx android. made main screen extends game, have blank screen , game screen play game. question create , render game. tried create texture in main screen , render in game screen. erros.

main screen:

package com.mygdx.paper; import com.badlogic.gdx.game; import com.badlogic.gdx.graphics.texture; import com.badlogic.gdx.graphics.g2d.spritebatch;  public class main extends game {       blank blankscreen;     game gamescreen;      @override     public void create() {             blackscreen = new blankscreen(this);             gamescreen = new blankscreen(this);             setscreen(blankscreen);       }  } 

blank screen:

package com.mygdx.paper;  import com.badlogic.gdx.gdx; import com.badlogic.gdx.screen; import com.badlogic.gdx.graphics.gl20;  public class blank implements screen {  main main;   public blank(main main) {     this.main= main; }  @override public void render(float delta) {      gdx.gl.glclearcolor(1, 1, 1, 1);     gdx.gl.glclear(gl20.gl_color_buffer_bit);     if (gdx.input.istouched())          main.setscreen(main.gamescreen); }  @override public void resize(int width, int height) { }  @override public void show() {  }  @override public void hide() {  }  @override public void pause() { }  @override public void resume() { }  @override public void dispose() {  } } 

game sceen

my game screen has in create, render. not work when click on blank screen.

here:

blackscreen = new blankscreen(this); gamescreen = new blankscreen(this); 

you set new blankscreen instance both screens: blackscreen and gamescreen. after touching blankscreen see anther blankscreen on..

you might want assign gamescreen (..or whatever games screen's class called) instead:

gamescreen = new gamescreen(this);  

btw: there nice tutorial screens in libgdx


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -