2
\$\begingroup\$

Apparently textButton.setScale() is not working. Even when the scale is set to 0.1, the button is displayed in it's original size.

How to properly scale a TextButton in LibGdx? The official documentation doesn't provide any details.

\$\endgroup\$
  • \$\begingroup\$ After setting the scale, have you tried setting its width and height like button.setWidth(button.getPrefWidth())? \$\endgroup\$ – StrongJoshua Jul 26 '15 at 17:46
  • \$\begingroup\$ @StrongJoshua Okay I tried it but that's not working either. \$\endgroup\$ – WeirdElfB0y Jul 26 '15 at 18:07
5
\$\begingroup\$

A little late but to answer my own question, you have to setTransform(true) if you're scaling a Button or Table. So in my case:

textButton.setTransform(true);
textButton.setScale(0.5f);
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

You should use a table to setup. Tables can be aligned and there cells sizes can change. You can do something like:

table.row();
table.add (tb).width (tb.width*scale);

What I did here is setting the cell with to the size of the table times a scale. You can set various variables on table cells. A table is a container widget and you have more of these. A button is a actor and best belongs to a container widget.

Sometimes tables and Scene2d work like a bitch and sometimes like a charm. Look them up in the document. I sent a link when not at my phone.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Hey it's you again! :D Thanks for this. I'll try the tables and update about it here. \$\endgroup\$ – WeirdElfB0y Jul 26 '15 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.