libgdx - scene2d.ui标签位置

时间:2014-10-18 20:05:48

标签: libgdx scene2d

如何将多行Label停靠在屏幕底部?有Label.setY()方法,但它以一种对我来说毫无意义的神秘方式起作用。我可以用getWrappedBounds()得到标签的近似高度,但我无法弄清楚如何使用标签的高度来设置标签的位置。

2 个答案:

答案 0 :(得分:2)

您无法直接定位标签,您必须添加到使用WidgetGroup的类(如Table)。或者您可以使用容器[应该比表格更轻量级]并添加标签:

Label testLabel = new Label("testme",super.getSkin(),"gameName");
Container labelContainer = new Container(testLabel);
labelContainer.bottom();

然后标签应显示在底部

答案 1 :(得分:0)

您应先准备好标签然后放置:

skorTextLabel = new Label("Score " + level_skoru, skorTextStyle);
skorTextLabel.setPosition(
            ekran_genisligi * 0.5f - skorTextLabel.getWidth() * 0.5f,
            skorTextLabel.getHeight() * 0.3f);

“skorTextLabel.getHeight()* 0.3f”距离底部的距离。

相关问题