简体   繁体   中英

How to make UI animation in Scene2d?

I am using a table in libgdx scene2d to group my labels for my score:

lblScore = new Label("Score: " + Integer.toString(score), labelStyle);
        lblBscore = new Label("Best: " + Integer.toString(bScore), labelStyle);

        table = new Table();
        table.setFillParent(true);
        table.setDebug(false);

        table.top();
        table.add(lblScore).padTop(Constant.HEIGHT / 2 - 100);
        table.row();
        table.add(lblBscore).padTop(10);
        stage.addActor(table);

What I want to happen is that when my character dies the table will show up with an animation, also is it a good idea that while my character is alive the table is just hidden? or should I just create the table when my character dies?

You didn't specify what kind of animation you wanted to do, but check out the Actions class as it has a bunch of actions you can use for animating Scene2d components (move, color change, fade in/out, rotate, etc):

https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/actions/Actions.html

And here is a tutorial with example code that demonstrates how to use the Actions:

http://www.gamefromscratch.com/post/2013/12/09/LibGDX-Tutorial-9-Scene2D-Part-2-Actions.aspx

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM