Libgdx |场景2d |设置表格的背景颜色? [英] Libgdx | Scene2d | Set background color of table?

查看:22
本文介绍了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. `

这篇关于Libgdx |场景2d |设置表格的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆