Trying to create a simple test app on my Samsung S9 using AIDE.
I have a main class that extends Game and another which implements Screen.
When the main class is created, it’s supposed to create a new Screen object and use setScreen to switch to the new screen.
The only rendering code picks a colour and clears the screen, each with a different clear colour, for me to know which part of the code is running.
The main class sets clear colour to white, while the screen class should set it to green.
When I run the code on my phone, it doesn’t appear to switch to the new screen.
Am I doing something wrong?
Main Class
public class MyGdxGame extends Game
{
@Override
public void create()
{
this.setScreen(new MainScreen(this));
}
@Override
public void render()
{
super.render();
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
//…
}
Menu Screen Class
public class MainScreen implements Screen {
private Game game;
private Stage stage;
public MainScreen(Game game) {
super();
this.game = game;
this.stage = new Stage();
}
@Override
public void show() {
Gdx.input.setInputProcessor(stage);
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 1, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(delta);
stage.draw();
}
//…
}