在我的游戏中,我想画一个2列的表格,其中包含正方形(如卡),在它们上面,一个图像和两个标签(作为一行,在卡的顶部是图像,下面是一个标签,下面是另一个标签)。
如果我只在可滚动的表格中放置图像,我会得到想要的结果,但现在我正试图在背景上添加图像和标签。
我尝试定义一个演员组并将其添加到表中,但有些元素没有出现,还扩展了Image类并在onDraw方法中绘制了其他元素,但当用户滚动时,文本不会随着卡片背景移动。
Table scrollTable = new Table();
scrollTable.align(Align.topLeft);
scrollTable.add(new HighScoreItem(game, Colors.ORANGE, "1º:FER", 30))
.width(190).height(150).space(30);
scrollTable.add(new HighScoreItem(game, Colors.ORANGE, "1º:FER", 30))
.width(190).height(150).space(30);
scrollTable.row();
scrollTable.add(new HighScoreItem(game, Colors.ORANGE, "1º:FER", 30))
.width(190).height(150).space(30);
scrollTable.add(new HighScoreItem(game, Colors.ORANGE, "1º:FER", 30))
.width(190).height(150).space(30);
scrollTable.row();
scrollTable.add(new HighScoreItem(game, Colors.ORANGE, "1º:FER", 30))
.width(190).height(150).space(30);
scrollTable.add(new HighScoreItem(game, Colors.ORANGE, "1º:FER", 30))
.width(190).height(150).space(30);
scrollTable.row();
scrollTable.add(new HighScoreItem(game, Colors.ORANGE, "1º:FER", 30))
.width(190).height(150).space(30);
scrollTable.add(new HighScoreItem(game, Colors.ORANGE, "1º:FER", 30))
.width(190).height(150).space(30);
scrollTable.row();
scrollTable.add(new HighScoreItem(game, Colors.ORANGE, "1º:FER", 30))
.width(190).height(150).space(30);
scrollTable.add(new HighScoreItem(game, Colors.ORANGE, "1º:FER", 30))
.width(190).height(150).space(30);
scrollTable.row();
ScrollPane scroller = new ScrollPane(scrollTable);
Table table = new Table();
table.setBounds(33, 10, 410, 500);
table.add(scroller).fill().expand();
getStage().addActor(table);
HighscoreItem是我用来显示表项的类。如果我用一个常规的Scene2D图像类替换这个类,所有内容都显示得很好,但尝试在背景上添加另一个图像和两个标签(通过使HighScoreItem从组扩展或通过使其从图像扩展)是个问题。
有什么办法吗?