Libgdx 带触摸板的精灵旋转

Libgdx 带触摸板的精灵旋转,libgdx,Libgdx,我有一个问题,或者只是不知道如何让它工作,所以一切都在图像中看到 rotation = lerp(rotation, realRotation, delta / 2); 您希望在特定角度(由触摸板设置)与原始(默认)值之间线性插值船舶旋转 我试图在我的代码中实现您的要求 public class TestGame1 extends Game { Stage stage; Touchpad touchpad; Image image; float angle=0

我有一个问题,或者只是不知道如何让它工作,所以一切都在图像中看到

rotation = lerp(rotation, realRotation, delta / 2);

您希望在特定角度(由触摸板设置)与原始(默认)值之间线性插值船舶旋转

我试图在我的代码中实现您的要求

public class TestGame1 extends Game {

    Stage stage;
    Touchpad touchpad;
    Image image;
    float angle=0;
    Texture shipTex;

    @Override
    public void create() {
        stage=new Stage();

        image=new Image(shipTex=new Texture("ship1.png"));
        image.setPosition(300,300);
        image.setSize(100,107);
        image.setOrigin(50,53);

        Skin skin=new Skin(Gdx.files.internal("skin/uiskin.json"));
        touchpad=new Touchpad(10,skin);
        touchpad.setPosition(100,100);
        Gdx.input.setInputProcessor(stage);

        stage.addActor(image);
        stage.addActor(touchpad);
    }

    @Override
    public void render() {

        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        Gdx.gl.glClearColor(0,0,0,1);

        stage.act();
        stage.draw();

        float knobX=touchpad.getKnobPercentX();
        float knobY=touchpad.getKnobPercentY();

        if(knobX!=0 && knobY!=0) {
            float radAngle = MathUtils.atan2(knobY, knobX);
            angle = MathUtils.radiansToDegrees * radAngle;
            angle -= 90;

            if (angle > 360)
                angle -= 360;
        }
        else
            angle=MathUtils.lerpAngleDeg(angle,0,Gdx.graphics.getDeltaTime());

        image.setRotation(angle);
    }

    @Override
    public void dispose() {
        stage.dispose();
        shipTex.dispose();
    }
}