Libgdx label rotation

2k Views Asked by At

Is it not possible to rotate a Label? It seems the API has that function but it doesn't seems to work? Are there anymore ways to rotate text?

Label nameLabel = new Label( "Test", skin);
nameLabel.setRotation( 90 );
stage.addActor( nameLabel );
2

There are 2 best solutions below

0
On

I've found it's not possible to rotate Labels, or Buttons or anything with text in libGDX. You can make an image and rotate it as a workaround.

3
On

You can wrap your label inside another Actor and rotate the parent Actor. So you will indirectly rotate the label, but the visible result is the same.

So you could create a parent actor for example like this:

public class LetterActor extends Group { //..

then for example in the constructor you add a Label to it:

this.addActor(someLabel);

then add a rotate action (or any other action!) to it:

this.addAction(Actions.rotateBy(90));

you may also need to set a height/width & origin for this parent actor