我想要旋转一个按钮。因此我写下了以下代码:
public void show () {
skin2 = new Skin (Gdx.files.internal("SettingsButton.json"));
button2 = new Button(skin2);
button2.setPosition(25,1440);
button2.setSize(120,120);
button2.setOrigin(button2.getWidth() / 2, button2.getHeight() / 2);
button2.addAction(Actions.repeat(RepeatAction.FOREVER,
Actions.sequence(
Actions.rotateBy(360, 1),
Actions.rotateTo(0))));
button2.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new SettingsScreen(game));
super.clicked(event, x, y);
}
});
stage.addActor(button2);
}
很遗憾,按钮没有旋转,但我不知道为什么。如何改进我的代码?
Actions.sequence(Actions.rotateBy(360, 1))
one rotation in one second by this action, if you want slower rotation increase time in sec.. like one rotation in 10 sec by thisActions.sequence(Actions.rotateBy(360, 10))
- Abhishek Aryan