【问题标题】:Libgdx center Scaled Textbutton in HorizontalGroupHorizo​​ntalGroup 中的 Libgdx 中心缩放文本按钮
【发布时间】:2020-09-16 22:54:27
【问题描述】:

将 TextBtton 放入 Horizo​​ntalGroup,然后缩放它们会导致视图扭曲,即使居中对齐也是如此。

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);

结果如下图:

似乎按钮位置是根据其未缩放的大小计算的。 如何纠正?

【问题讨论】:

    标签: java libgdx scene2d


    【解决方案1】:

    为此,我最终使用了表格:

    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);
    

    像魅力一样工作!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-27
      • 1970-01-01
      • 2016-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多