Libgdx center Scaled Textbutton в HorizontalGroup - PullRequest
0 голосов
/ 29 мая 2020

Помещение TextBttons в HorizontalGroup, а затем их масштабирование приводит к искаженному виду даже с выравниванием по центру.

add_button = new TextButton("+",textButtonStyle);
add_button.setTransform(true);
add_button.setScale(0.7f);
add_button.setDebug(true);
remove_button = new TextButton("-",textButtonStyle);
remove_button.setTransform(true);
remove_button.setScale(0.7f);
remove_button.setDebug(true);

HorizontalGroup brush_op_group = new HorizontalGroup();
brush_op_group.addActor(remove_button);
brush_op_group.addActor(add_button);
brush_op_group.setDebug(true);

, что приводит к изображению ниже:

enter image description here

Похоже, что позиции кнопок рассчитываются исходя из их немасштабированных размеров. Как это исправить?

1 Ответ

0 голосов
/ 29 мая 2020

Для этой цели я использовал таблицы:

add_button = new TextButton("+",textButtonStyle);
add_button.setTransform(true);
add_button.setOrigin(Align.left | Align.top);
add_button.setScale(0.8f);
remove_button = new TextButton("-",textButtonStyle);
remove_button.setTransform(true);
remove_button.setOrigin(Align.right | Align.top);
remove_button.setScale(0.8f);

HorizontalGroup file_op_group = new HorizontalGroup();
Table brush_op_group = new Table().center();
brush_op_group.add(remove_button).right();
brush_op_group.add(add_button).left();
brush_op_group.setDebug(true);

Работает как шарм!

enter image description here

...