How to keep rotating a button on main menu screen around its center, here's the code for the button

final ImageButton btnSett=UIFactory.createButton(txtrSettings);
btnSett.setPosition(Gdx.graphics.getWidth()/ 2,0.f, Align.center);

1 Answer 1


Try applying an Action to the button.

For example, to make the Button rotate once apply a rotate action:

btnSett.addAction(Actions.rotateBy(360, 1));

This will rotate btnSett once over one second. To make something continuously rotate you can apply a repeated action, and actions can also be in sequence, for example;

                     Actions.rotateBy(360, 1), // First, rotate once   
                     Actions.rotateTo(0));     // Then, instantly set the rotation to 0 so that the previous action makes sense again.

You'll also need to set the origin of the Button to it's center first;

btnSett.setOrigin(btnSett.getWidth() / 2, btnSett.getHeight() / 2);

To make the actions code look cleaner consider making static imports of the methods in Actions, that way the code can look more like;

                         sequence(rotateBy(360, 1), 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .