Skip to content

ProgressBar#setAnimateDuration(float) is broken #2947

@dermetfan

Description

@dermetfan

Probably since e15b3f4.

Here's a test. The ProgressBar's knob should slide to left and right repeatedly but is just set there without animation.

public class ProgressBarTest extends GdxTest implements Screen {

    private Stage stage;
    private ProgressBar bar;

    @Override
    public void create() {
        Gdx.input.setInputProcessor(stage = new Stage());
        Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));

        Table table = new Table(skin);
        table.setFillParent(true);

        bar = new ProgressBar(0, 100, 1, false, skin);
        bar.setAnimateDuration(.75f);

        table.add(bar).size(500, 10);

        stage.addActor(table);
    }

    float time, duration = 1;

    @Override
    public void render() {
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        float delta = Gdx.graphics.getDeltaTime();

        if((time += delta) > duration) {
            bar.setValue(bar.getValue() < 50 ? 100 : 0);
            time = 0;
        }

        stage.act(delta);
        stage.draw();
    }

    @Override
    public void resize(int width, int height) {
        stage.getViewport().update(width, height, true);
    }

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

    // if used as Screen

    @Override
    public void show() {
        create();
    }

    @Override
    public void render(float delta) {
        render();
    }

    @Override
    public void hide() {}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions