1

我有这个(工作正常):

public static Texture bubble1 = new Texture(Gdx.files.internal("Bubble1.png"));
public static Texture bubble2 = new Texture(Gdx.files.internal("Bubble2.png"));
public static Texture bubble3 = new Texture(Gdx.files.internal("Bubble3.png"));
public static Texture bubble4 = new Texture(Gdx.files.internal("Bubble4.png"));

我试了一下(不以任何方式工作):

String fileName;
Texture[] bubble;
bubble = new Texture[4];

for (int i = 0; i < 4; i++){
    fileName = String.format("Bubble%1d", i+1);
    bubble[i] = new Texture(Gdx.files.internal(fileName));
}

怎么了?在保持代码的简单性和通用性的同时,我能做些什么来完成这项工作?非常感谢!

4

1 回答 1

2

Maybe you forgot .png?

for (int i = 0; i < 4; i++)
{
    fileName = String.format("Bubble%1d.png", i+1);
    bubble[i] = new Texture(Gdx.files.internal(fileName));
}
于 2013-10-29T09:02:47.013 回答