如何使用libGDX更改Scene2D图像中的纹理?

Vol*_*ort 10 libgdx

如何更改Scene2D图像中的纹理?

http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Image.html

文档中没有这样的方法.我通过为其构造函数提供纹理引用来创建我的.

noo*_*one 20

你必须改变drawable并将你的新纹理包裹在一个 SpriteDrawable

Texture texture = ...;
Image image = new Image(texture);

// switch to a new texture
Texture newTexture = ...;
image.setDrawable(new SpriteDrawable(new Sprite(newTexture)));
Run Code Online (Sandbox Code Playgroud)