Mixing a ProgressBar Effect With a Button

Anything libgdx related goes here!

Mixing a ProgressBar Effect With a Button

Postby shatterblast » Sat Jan 13, 2018 7:58 pm

I recently discovered the awesomeness known as a "loading bar". It basically involves layering two NinePatch images on top of each other as the top NinePatch stretches in unison with "manager.getProgress()". I desire to use a similar concept with the Button class of Scene2D. I believe it will require the Cell class to properly stretch something like a NinePatchDrawable.

At the core, I am mixing the concept of a loading bar with a Button. With my limited knowledge, I do not know if I could even animate a ProgressBar inside a Button. Layering at least two items over each other could provide the illusion of a single button. For the purpose of presenting an individual "button" in code, the visuals could stay together in a single Table object. I will test the idea soon, but I believe one Table can hold another Table. Thus, a Table object revealing multiple "fake buttons" should work.

Would anyone have a better idea? Thank you for bearing with me.
shatterblast
 
Posts: 47
Joined: Sun Jul 06, 2014 1:14 pm

Re: Mixing a ProgressBar Effect With a Button

Postby evilentity » Sat Jan 13, 2018 8:13 pm

Eh?
Code: Select all
progress = new ProgressBar(0, 1, .01f, false, skin, "horizontal");
progress.addListener(new ClickListener(){
            @Override public void clicked (InputEvent event, float x, float y) {
                Gdx.app.log(TAG, "welp");
            }
        });
Looking for a freelancer? PM me!
evilentity
 
Posts: 4062
Joined: Wed Aug 24, 2011 11:37 am

Re: Mixing a ProgressBar Effect With a Button

Postby shatterblast » Sat Jan 13, 2018 8:23 pm

evilentity wrote:Eh?
Code: Select all
progress = new ProgressBar(0, 1, .01f, false, skin, "horizontal");
progress.addListener(new ClickListener(){
            @Override public void clicked (InputEvent event, float x, float y) {
                Gdx.app.log(TAG, "welp");
            }
        });


True, and a ProgressBar could be shaped to look like a specific Button. Even the Actions class could be used for a ".fadeOut()" effect to another Button, and a separate Label could be kept over them so that the text does not fade.

Thank you.
shatterblast
 
Posts: 47
Joined: Sun Jul 06, 2014 1:14 pm

Re: Mixing a ProgressBar Effect With a Button

Postby tenfour04 » Sun Jan 14, 2018 2:42 am

A button is a Table, so make a button with an empty style and add your progress bar to it.
tenfour04
 
Posts: 1136
Joined: Sat Jun 18, 2011 3:24 pm

Re: Mixing a ProgressBar Effect With a Button

Postby shatterblast » Sun Jan 14, 2018 8:04 am

tenfour04 wrote:A button is a Table, so make a button with an empty style and add your progress bar to it.


Please excuse my mis-understanding. I thought that "Button.ButtonStyle" would not accept an Actor.
shatterblast
 
Posts: 47
Joined: Sun Jul 06, 2014 1:14 pm

Re: Mixing a ProgressBar Effect With a Button

Postby DranikProgrammer » Sun Jan 14, 2018 10:16 am

The actual Button class is a widget group by itself, so you can add widgets to it like you would normally add them to windows, tables etc.
DranikProgrammer
 
Posts: 91
Joined: Mon Feb 20, 2017 2:51 pm

Re: Mixing a ProgressBar Effect With a Button

Postby tenfour04 » Sun Jan 14, 2018 8:08 pm

Sorry, bad wording. Use a style with no background on the Button. Add your Progress Bar to the button.

Although the ClickListener on a ProgresBar may be fine. The downside is it won't support disabled state and toggling without you coding it yourself. Amd with the button, you could give it a nine patch background that surrounds your progress bar and reacts to touches with color changes.
tenfour04
 
Posts: 1136
Joined: Sat Jun 18, 2011 3:24 pm

Re: Mixing a ProgressBar Effect With a Button

Postby evilentity » Sun Jan 14, 2018 8:30 pm

It really depends on what you want to achieve, mixing progress bar with a button isnt very specific.
Looking for a freelancer? PM me!
evilentity
 
Posts: 4062
Joined: Wed Aug 24, 2011 11:37 am

Re: Mixing a ProgressBar Effect With a Button

Postby shatterblast » Mon Jan 15, 2018 1:48 pm

(@tenfour04) and (@DranikProgrammer)

Thank you for the clarity. Due to the suggestions, I believe I understand finally the "java.lang.String styleName" part of ProgressBar's second constructor. It functions along with the "Style" heading in the top-right of Raeleus's Skin Composer. I think this path should serve well for modifying the height of a horizontally placed ProgressBar. Otherwise, my attempts at changing just the height in code fail. (My current "skin" has a few extra choices for the size in it.)

I think this is enough information to point me in the right direction. Thank you again all for contributing!
shatterblast
 
Posts: 47
Joined: Sun Jul 06, 2014 1:14 pm


Return to Libgdx

Who is online

Users browsing this forum: No registered users and 18 guests