【发布时间】:2014-05-03 13:23:55
【问题描述】:
我想交换 libGDX 表中两个标签的位置。我想我可以使用 swapActors 来做到这一点,但它没有解决问题。
private Stage stage;
private Table table;
public MainScreen() {
stage = new Stage(new FitViewport(800, 480));
table = new Table(SkinManagerImpl.getDefaultSkin());
table.add("A").center();
table.add("B").center();
table.setFillParent(true);
boolean succes=table.swapActor(0, 1);
Gdx.app.log("", "success:"+succes);
table.layout();
stage.addActor(table);
}
@Override
public void render(float delta) {
// TODO Auto-generated method stub
super.render(delta);
stage.draw();
}
success 是真的,但它仍然按要求说“AB”而不是“BA”。
还有另一种简单的方法来交换表格内的两个单元格或演员(意思是交换位置)吗?
【问题讨论】:
-
难道你不能只使用 Vector2 来保存每个精灵的 x 和 y 位置,并在渲染之间简单地切换值吗?
-
如果每个精灵坐在桌子上,我不会更改它们的 x 和 y。不知道会发生什么,因为桌子会为你设置它们的位置。
-
您好,您找到解决方案了吗?