我想在逆時針方向旋轉不停環像這裏是我的代碼旋轉圖像連續
public class SpriteSheet extends ApplicationAdapter {
Stage stage;
@Override
public void create() {
stage=new Stage(new ScreenViewport());
Group group=new Group();
Image background =new Image(new Texture(Gdx.files.internal("background.png")));
Image button=new Image(new Texture(Gdx.files.internal("btn.png")));
Image ring=new Image(new Texture(Gdx.files.internal("ring2.png")));
background.setName("background");
button.setName("button");
ring.setName("ring");
group.addActor(background);
group.addActor(button);
group.addActor(ring);
stage.addActor(group);
background.setPosition(Gdx.graphics.getWidth()/2-background.getWidth()/2,Gdx.graphics.getHeight()/2-background.getHeight()/2);
button.setPosition(Gdx.graphics.getWidth()/2-button.getWidth()/2,Gdx.graphics.getHeight()/2-button.getHeight()/2);
ring.setPosition(255,105);
ring.setOrigin(255f,105f);
ring.rotateBy(2f); // I need continuous rotation here
}
@Override
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
}
只需使用一個循環 –
你有什麼問題?你現在擁有哪個結果? –
ring.rotateBy(2f);既沒有旋轉也沒有給出恆定的旋轉 – dilz