Java 在屏幕上绘制后更改特定的图像样式

Java 在屏幕上绘制后更改特定的图像样式,java,android,libgdx,Java,Android,Libgdx,我正在我的LibGDX应用程序中构建一个小菜单。 我有一些按钮,我从同一个资源中绘制,在它们上面我放置了不同的图像标签。 创建按钮后,我正在寻找更新按钮的方法 我在循环中运行了10次,创建了ImageButtom,并将其添加为Actor for (int i=0; i<10; i++ ) { ImageButtonStyle style = new ImageButtonStyle() ; style.up = skin.getDrawable(i);

我正在我的
LibGDX
应用程序中构建一个小菜单。 我有一些按钮,我从同一个资源中绘制,在它们上面我放置了不同的图像标签。 创建按钮后,我正在寻找更新按钮的方法

我在循环中运行了10次,创建了
ImageButtom
,并将其添加为
Actor

for (int i=0; i<10; i++ ) {

        ImageButtonStyle style = new ImageButtonStyle() ;
        style.up = skin.getDrawable(i);
        style.down = skin.getDrawable(i);
        ImageButton image = new ImageButton(styleButton);
        addActor(image);     
        }

for(int i=0;i如果我理解你想要什么,或者如果这是最有效的方法,则不是,但我碰巧读到了你的问题:

for (int i=0; i<10; i++ ) {

    ImageButtonStyle style = new ImageButtonStyle() ;
    style.up               = skin.getDrawable(i);
    style.down             = skin.getDrawable(i);
    ImageButton image      = new ImageButton(styleButton);

    image.setName("styleNumber"+i); // or use Integer.toString(i);

    addActor(image);     
    }
for(int i=0;例如:“styleNumber1”
for(int a=0;a
将图像保存在数组或其他结构中:

import com.badlogic.gdx.utils.Array;

Array<ImageButton> myImageButtons = new Array<ImageButton>(10);


for (int i=0; i<10; i++ ) {
        ImageButtonStyle style = new ImageButtonStyle() ;
        style.up = skin.getDrawable(i);
        style.down = skin.getDrawable(i);
        ImageButton image = new ImageButton(styleButton);
        addActor(image);     

        myImageButtons.add(image);
}
import com.badlogic.gdx.utils.Array;

Array<ImageButton> myImageButtons = new Array<ImageButton>(10);


for (int i=0; i<10; i++ ) {
        ImageButtonStyle style = new ImageButtonStyle() ;
        style.up = skin.getDrawable(i);
        style.down = skin.getDrawable(i);
        ImageButton image = new ImageButton(styleButton);
        addActor(image);     

        myImageButtons.add(image);
}
void ImageButton getButtonImage(int i) {
    return myImageButtons.get(i);
}