按钮无法旋转libGDX

5

我想要旋转一个按钮。因此我写下了以下代码:

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

很遗憾,按钮没有旋转,但我不知道为什么。如何改进我的代码?
1个回答

12

谢谢!有没有设置旋转速度的可能性? - user8340536
旋转速度是什么意思? - Abhishek Aryan
我想设置按钮在一定时间内旋转的次数,例如每分钟一次旋转比每分钟五次旋转慢。因此,我想进行设置。 - user8340536
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 this Actions.sequence(Actions.rotateBy(360, 10)) - Abhishek Aryan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接