8

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 );
donfuxx
  • 11,277
  • 6
  • 44
  • 76
pakito
  • 387
  • 2
  • 3
  • 17

2 Answers2

11

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

donfuxx
  • 11,277
  • 6
  • 44
  • 76
  • why this doesn't work for me? what do I have forgotten? tried it with group - withouth group, with addAction(rotateBy(90)) with just rotateBy(90) with setRotation(90).. nothing happens to the rotation – Suisse Nov 08 '16 at 17:56
  • you need to add the rotate action to the Group and the group needs to have the label added as a child actor – donfuxx Nov 10 '16 at 09:32
  • make sure you have setTransform(true) on the group, so that transformations applied to the group filter down to the text – Moz Mar 30 '21 at 03:22
-2

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.

Barodapride
  • 3,475
  • 4
  • 25
  • 36