I am not able to add actors (Actor) on a Screen. I want to show an actor in "ScreenMenu" and nothing happens (the actor does not appear), follow me code:
MainClass.java
public class MainClass extends Game{
public static Stage stage;
private OrthographicCamera gameCam;
private Viewport gamePort;
public static int V_WIDTH = 0;
public static int V_HEIGHT =0;
public SpriteBatch batch;
@Override
public void create() {
V_WIDTH = Gdx.graphics.getWidth();
V_HEIGHT = Gdx.graphics.getHeight();
gameCam = new OrthographicCamera();
gamePort = new FitViewport(V_WIDTH,V_HEIGHT, gameCam);
batch = new SpriteBatch();
stage = new Stage();
setScreen(new ScreenMenu(this));
}
@Override
public void dispose() {
super.dispose();
}
@Override
public void render() {
super.render();
Gdx.gl.glClearColor(color.r, color.g, color.b, color.a);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw();
}
ScreenMenu.java
public class ScreenMenu implements Screen {
public static Stage stage;
private Viewport viewport;
public SpriteBatch batch;
BotaoTrovaoActor btn;
private MainClass mainClass;
public ScreenMenu(MainClass mc)
{
mainClass=mc;
}
@Override
public void show() {
stage = new Stage();
batch = new SpriteBatch();
btn = new BotaoTrovaoActor();
btn.setBounds(100,400 , 72, 72);
stage.addActor(btn);
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw();
}
@Override
public void resize(int width, int height) {
}
@Override
public void pause() {
}
@Override
public void resume() {
}
@Override
public void hide() {
}
@Override
public void dispose() {
}
}