如何改变Scene2D图像中的纹理?
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Image.html
在文档中没有这样的方法。我通过为构造函数提供纹理引用来创建我的。
发布于 2014-02-01 07:34:47
您必须更改绘图,并将新纹理包装在SpriteDrawable中。
Texture texture = ...;
Image image = new Image(texture);
// switch to a new texture
Texture newTexture = ...;
image.setDrawable(new SpriteDrawable(new Sprite(newTexture)));发布于 2017-12-18 14:57:21
您可以使用:
Texture texture = ...;
Image image = new Image(texture);
// change to a new texture
Texture newTexture = ...;
image.setDrawable(new TextureRegionDrawable(new TextureRegion(newTexture)));不使用SpriteDrawable或创建新的Sprite实例。
https://stackoverflow.com/questions/21495258
复制相似问题