Libgdx |场景2d |设置表格的背景颜色?
我正在创建一个菜单(就像那个是飞扬的鸟,当你死后它会在播放屏幕上弹出).我创建了一个扩展表格的类,我想将表格的背景设置为白色.有没有办法做到这一点?
I am creating a menu (like the one is flappy bird, when you die it pops up over the play screen). I created a class that extends table, and I want to set the background of the table to white. Is there a way to do this?
推荐答案
你可以这样做:
Pixmap bgPixmap = new Pixmap(1,1, Pixmap.Format.RGB565);
bgPixmap.setColor(Color.RED);
bgPixmap.fill();
textureRegionDrawableBg = new TextureRegionDrawable(new TextureRegion(new Texture(bgPixmap)));
Table table = new Table();
table.setBackground(textureRegionDrawableBg);
记得在纹理和像素图上调用 dispose().`
Remember to call dispose() on the texture and on the pixmap. `
相关文章