Reputation: 11665
The content of Table B and D are equal. The only difference is, that Table D is in a Actor:
Question: Why is the Actor not correct positioned ? It is cenetered to the bottom left of Table A(Table A = blue). Could manually position Actor C, but I would like to understand, whats wrong here.
Code:
Table outerTable = createOuterTable(font, skin);
outerTable.debug();
outerTable.setPosition(200,200);
stage.addActor(outerTable);
private Table createTable_B(BitmapFont font){
Table table = new Table();
Label.LabelStyle labelStyle = new Label.LabelStyle(font, new Color(Color.GREEN));
Label firstlabel = new Label("Table B row 1", labelStyle);
Label secondlabel = new Label("Table B row 2", labelStyle);
table.add(firstlabel);
table.row();
table.add(secondlabel);
table.debug();
return table;
}
private Table createOuterTable(BitmapFont font, Skin skin){
Table table = new Table();
TableActor actor_C = new TableActor(skin);
table.add(createTable_B(font)).pad(20);
table.row();
table.add(actor_C).pad(20);
table.debug();
return table;
}
public class TableActor extends Group {
private final BitmapFont font;
public TableActor(Skin skin) {
font = skin.get(Label.LabelStyle.class).font;
Table table = createInnerTable(font);
addActor(table);
setTransform(false);
}
private Table createInnerTable(BitmapFont font){
Table table = new Table();
Label.LabelStyle labelStyle = new Label.LabelStyle(font, new Color(Color.GREEN));
Label firstlabel = new Label("Table D row 1", labelStyle);
Label secondlabel = new Label("Table D row 2", labelStyle);
table.add(firstlabel);
table.row();
table.add(secondlabel);
table.debug();
return table;
}
Upvotes: 0
Views: 99
Reputation: 1791
Use Container
instead of Group
and check the code in Container
to understand what's wrong when only using Group
.
Upvotes: 1