The .setRotation() or .rotateBy() functions work on other Actor classes but not on ProgressBar objects.
Am I missing something here?
public void create() {
stage = new Stage(new ScreenViewport());
Gdx.input.setInputProcessor(stage);
skin = new Skin();
Pixmap pixmap = new Pixmap(10, 10, Pixmap.Format.RGBA8888);
pixmap.setColor(Color.WHITE);
pixmap.fill();
skin.add("white", new Texture(pixmap));
TextureRegionDrawable textureBar = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("blue.jpg")))); // Just a blue square
ProgressBar.ProgressBarStyle barStyle = new ProgressBar.ProgressBarStyle(skin.newDrawable("white", Color.DARK_GRAY), textureBar);
progressBar = new ProgressBar(0,10,0.5f,false, barStyle);
progressBar.setPosition(10, 10);
progressBar.setSize(290, progressBar.getPrefHeight());
progressBar.setAnimateDuration(2);
progressBar.setValue(5);
progressBar.setRotation(45); // Should rotate the bar
stage.addActor(progressBar);
}
Also if I call .getRotation() I get whatever I set it previously so I'm not sure what is the problem here.
Most UI widgets cannot be transformed directly , due to performance reasons. There are still getters/setters for rotation though, this can be confusing.
However it is possible to put them in a Group
and transform the group.
ProgressBar progressBar = ...
Group g = new Group();
g.addActor(progressBar);
g.setRotation(45);
stage.addActor(g);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.