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\$
2
  • \$\begingroup\$ After setting the scale, have you tried setting its width and height like button.setWidth(button.getPrefWidth())? \$\endgroup\$ Jul 26, 2015 at 17:46
  • \$\begingroup\$ @StrongJoshua Okay I tried it but that's not working either. \$\endgroup\$
    – Neerkoli
    Jul 26, 2015 at 18:07

2 Answers 2

6
\$\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);
\$\endgroup\$
1
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.

\$\endgroup\$
1
  • \$\begingroup\$ Hey it's you again! :D Thanks for this. I'll try the tables and update about it here. \$\endgroup\$
    – Neerkoli
    Jul 26, 2015 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .