pakito
pakito

Reputation: 387

Libgdx label rotation

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 );

Upvotes: 8

Views: 2078

Answers (2)

donfuxx
donfuxx

Reputation: 11323

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

Upvotes: 11

Barodapride
Barodapride

Reputation: 3723

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.

Upvotes: -2

Related Questions