【问题标题】:libgdx Group is not affected by parent Table.row()libgdx 组不受父 Table.row() 的影响
【发布时间】:2014-05-29 23:17:42
【问题描述】:

我正在尝试使用 Table 类创建游戏内窗口。但是当我将图像组添加到该表时,似乎 row() 方法对组没有影响,它们都在同一个地方。使用图像而不是组有效。 PS。我使用 Group 来重叠图像(有点悬停效果的边框),不知道更好的方法。 谢谢

public class MyGroup extends Group{
        public  MyGroup(Image bg, Image thumb){
            this.addActor(bg);
            this.addActor(thumb);
        }
    }

public class ActionScreen extends Table {

 MyGroup[] group =new MyGroup[8];
for (int i=0;i<8;i++){
            group[i] =  new MyGroup(new Image(skin.getDrawable("item-bg")),new Image(skin.getDrawable("item-bg-over")));
            if (i==4){
                row();
                add(group[i]).top().padLeft(100);
            }
            else{
                add(group[i]).top().padLeft(100);
            }
        }

【问题讨论】:

    标签: java user-interface libgdx scene2d


    【解决方案1】:

    默认情况下,组的大小为零,因此您必须手动设置大小。

    在你的 MyGroup 构造函数中,你会想调用这样的东西

    this.setSize(bg.getWidth(), bg.getHeight());
    

    【讨论】:

      猜你喜欢
      • 2016-04-23
      • 2015-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 2019-04-19
      相关资源
      最近更新 更多