animated menu buttons

Anything libgdx related goes here!

animated menu buttons

Postby TruePlayer » Tue Aug 13, 2019 12:47 am

I recently saw examples on YouTube how the buttons in the game menu sliding from the down bottom and took their positions, how is this done? maybe somewhere there is an article?
TruePlayer
 
Posts: 54
Joined: Sun Jul 28, 2019 12:22 pm

Re: animated menu buttons

Postby evilentity » Tue Aug 13, 2019 7:59 am

You can do that with Actions.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4833
Joined: Wed Aug 24, 2011 11:37 am

Re: animated menu buttons

Postby shatterblast » Tue Aug 13, 2019 2:54 pm

It is possible to move an Actor, like a Button, at a constant rate, and then after a certain point, apply Interpolation.BounceIn or similar so that it gradually slows down to a halt into your planned resting place for it. I think you would want to multiply your math that causes the Actor's movement by the Interpolation math once your Actor gets close enough. Once there, you might just set the Actor, Button, or whatever exactly where it should be. For example, you would not want a Button sitting at X = 0.00013f by Y = 76.0043f or some weird related non-sense. Otherwise, Android definitely will not like it, and things become considerably much harder to click on the touch screen.
https://libgdx.badlogicgames.com/ci/nig ... ation.html
shatterblast
 
Posts: 368
Joined: Sun Jul 06, 2014 1:14 pm

Re: animated menu buttons

Postby TruePlayer » Tue Aug 13, 2019 8:28 pm

evilentity wrote:You can do that with Actions.

it would be nice if your answer contained more than a few words)

shatterblast wrote:It is possible to move an Actor


make the buttons actors and work with them on stage I’ll try to do
TruePlayer
 
Posts: 54
Joined: Sun Jul 28, 2019 12:22 pm

Re: animated menu buttons

Postby shatterblast » Tue Aug 13, 2019 9:18 pm

A Button is already an Actor.
shatterblast
 
Posts: 368
Joined: Sun Jul 06, 2014 1:14 pm

Re: animated menu buttons

Postby TruePlayer » Wed Aug 14, 2019 1:16 am

shatterblast wrote:A Button is already an Actor.

Code: Select all
gameButton = new TextButton("GAME",skin, "default");
        gameButton.setWidth(200f);
        gameButton.setHeight(50f);
        gameButton.setPosition(game.getWeight() /2 - 100f, game.getHeight()/2 - 10f);
        gameButton.addListener(new ClickListener(){
            @Override
            public void clicked(InputEvent event, float x, float y){
                gsm.setState(2);
                dispose();
            }
        });


this is my button, should I override the act or update method to change the drawing coordinates? Need to write your own wrapper class for a button?
TruePlayer
 
Posts: 54
Joined: Sun Jul 28, 2019 12:22 pm

Re: animated menu buttons

Postby shatterblast » Wed Aug 14, 2019 6:04 am

TruePlayer wrote:should I override the act or update method to change the drawing coordinates?

"setPosition()" will affect where your "gameButton" will go. The existing values you have in it should first center "gameButton" in a Window and then the offset will move it away from that center. You might just set it similar to the following if you want to try something simpler:
Code: Select all
gameButton.setPosition( 100f, 100f );

https://libgdx.badlogicgames.com/ci/nig ... oat-float-


TruePlayer wrote: Need to write your own wrapper class for a button?

Not really. There should be no need to override either act() or update(). The point of adding many Actor related objects to a Stage is so that you can just call its draw() method once instead of needing to tediously call draw() on each and every single thing that inherits from Actor. Also, it makes organizing things much easier if you like the concept of layers.
shatterblast
 
Posts: 368
Joined: Sun Jul 06, 2014 1:14 pm

Re: animated menu buttons

Postby evilentity » Wed Aug 14, 2019 9:21 am

I can point you in a direction of one of the solutions, not going to do your homework for you.
https://github.com/libgdx/libgdx/wiki/Scene2d#actions
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4833
Joined: Wed Aug 24, 2011 11:37 am

Re: animated menu buttons

Postby TruePlayer » Wed Aug 14, 2019 3:30 pm

evilentity wrote:I can point you in a direction of one of the solutions, not going to do your homework for you.
https://github.com/libgdx/libgdx/wiki/Scene2d#actions

I never ask you to do the work for me, I don’t even ask for the code. I ask only a detailed answer, exhortation, advice from a colleague
TruePlayer
 
Posts: 54
Joined: Sun Jul 28, 2019 12:22 pm


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot] and 1 guest