Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 );
like image 302
pakito Avatar asked Nov 18 '14 07:11

pakito


1 Answers

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

like image 51
donfuxx Avatar answered Oct 22 '22 16:10

donfuxx