I plan on having an animated character (the character image changes several times to make it seem moving), and I would like to know how to do it. I am currently planning to do something like this:
String fileLocation = "./images/picture"; BufferedImage img; int numImages = 10; for(int i = 0; i < numImages; i++){ img = ImageIO.read(new File(fileLocation + i + ".png")); Thread.sleep(100); g.drawImage(img, 0, 0, null); }
This is an incredibly simplified version, skipping a few things, but I'm sure you understand what I mean. Are there any problems with this? (Note: the for loop will be repeated again after completion, and in the "images" folder there will be files called "picture0.png", "picture1.png", etc.)
source share