Reputation: 9
I have this (works fine):
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"));
And i try it (do not work in any way):
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));
}
What is wrong? What can I do to make this work while maintaining the simplicity and generality of the code? Thank you very much!
Upvotes: 1
Views: 888
Reputation: 1249
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));
}
Upvotes: 2