I'm new to Libgdx, and I was written a class that extends the Game class, the fact is that the setScreen () method from Game does not change screens, because after setting the screen, my game still displays only what is in the rendering method from the game class, not what is in the screen class rendering method. This is the code:
If I run this code, I get only a red screen, even if I change the screens when the user touches the screen
class myGame extends Game { GameScreen myOtherScreen; public void create() { //create other screen myMenuScreen = new GameScreen(); } public void render(float delta) { // change screens if screen touched if(Gdx.input.justTouched()) setScreen(myOtherScreen); //render red screen Gdx.gl.glClearColor(1, 0, 0, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); } . . //other methods . } // ======= Screen Class ======== public class GameScreen implements Screen { @Override public void render(float delta) { //render green screen Gdx.gl.glClearColor(0, 1, 0, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); } . . //other methods . }
source share