Libgdx: Is there an easy way to center text on each axis on a button?

后端 未结 3 657
無奈伤痛
無奈伤痛 2021-01-17 08:43

I have been trying to figure out a way to center text on a button, but can\'t find an easy, multi-purpose way to. I can do it, but it will only work for a certain string, no

3条回答
  •  被撕碎了的回忆
    2021-01-17 08:55

    Try the following:

    label.setPosition(Gdx.graphics.getWidth()/2-(label.getPrefWidth()/2),Gdx.graphics.getHeight()-(label.getPrefHeight()/2));
    

提交回复
热议问题