I'm reading a couple images with the exact same name but numbered from 1-6 so I've used and array to read in the images, for example AstroWalkLeft1, AstroWalkLeft2 into arimgAstroWalkleft[]. This is what I have:
public void GetImages() {
imgMonster = new ImageIcon("Assets\\MonsterSingle.png").getImage();
for (int i = 1; i <= nASTROIMGMAX; i++) {
arimgAstroWalkLeft[i] = new ImageIcon("Assets\\AstroWalkLeft" + i + ".png").getImage();
arimgAstroWalkRight[i] = new ImageIcon("Assets\\AstroWalkRight" + i + ".png").getImage();
}
imgAstroStandLeft = new ImageIcon("Assets\\AstroStandLeft.png").getImage();
imgAstroStandRight = new ImageIcon("Assets\\AstroStandRight.png").getImage();
imgBackground1 = new ImageIcon("Assets\\Hallway.png").getImage();
imgBackground2 = new ImageIcon("Assets\\Observation Room.png").getImage();
}
My problem is replacing the numbers in the image's name to the variable in my loop. I'm wonder how I put that variable in where the number once was.