When I'm adding the same TextButton multiple times in my table, only the last one will be displayed:
public void show(){
button = new TextButton("Hello", textButtonStyle);
stage.addActor(button);
final Table table = new Table();
table.add(button);
table.row();
table.add(button);
table.row();
table.add(button);
table.setFillParent(true);
table.debug();
stage.addActor(table);
}
public void render(float delta) {
stage.act();
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw();
}
What am I doing wrong?
addActor(actor)
method called when you're adding a Actor
to table by using add(..)
.
because Table
is inherently a Group
and according to doc :
When we call addActor(actor)
method of Group
Adds an actor as a child of that group, removing it from its previous parent. If the actor is already a child of that group, no changes are made.
so create different object of required Actor
and add them on table.