libgdx tablelayout在新行中添加图像
我在屏幕中使用libgdx和表布局 当我在初始化时在表中添加图像时一切正常,但当我在某些事件(碰撞时)中将图像添加到表中时,图像被放置在一列中,而不是新行中的每个图像libgdx tablelayout在新行中添加图像,libgdx,tablelayout,Libgdx,Tablelayout,我在屏幕中使用libgdx和表布局 当我在初始化时在表中添加图像时一切正常,但当我在某些事件(碰撞时)中将图像添加到表中时,图像被放置在一列中,而不是新行中的每个图像 Table tableCenterLeft; Image image1, image2; private void init() { tableCenterLeft = new Table(); image1 = new Image(Assets.instance.image.image1
Table tableCenterLeft;
Image image1, image2;
private void init() {
tableCenterLeft = new Table();
image1 = new Image(Assets.instance.image.image1);
image1 = new Image(Assets.instance.image.image1);
createUI();
}
private void createUI() {
//if I add image here in init() image1 and image2 are added one below the other (fine)
tableCenterLeft.add(image1);
tableCenterLeft.add(image2);
}
private void onCollisionWithRock() {
// if I add in some event later in game , image1 and image2 are in same column (bad)
tableCenterLeft.add(image1);
}
有什么想法吗?
谢谢如果您希望您的表中有一行新行,请在
tableCenterLeft.add(image1)
之前调用tableCenterLeft.row()
使用您的方法
createUI
,两个图像应该位于同一行。我希望位于同一行,但它们彼此位于新行。当我一次一次地延迟调用onCollisionWithRock
方法时就是这种情况(一次调用image1,一次调用image2)