0

I want to change images at a specific location, for the purpose of animation. Can I create a loop with for change in file names. File names are like Sprite1.png, Sprite2.png ...... Sprite10.png.

for(i = 1; i <= 10; i++) 
{
    Display("Sprite(i).png")
}

Is something like this possible? How?

Nic
  • 12,220
  • 20
  • 77
  • 105
  • Yes, it's possible, but it's much more complicated then you think it is. Basically you need to know how many frames the sprite has and what frame you are currently displaying, from this you can determine the image which should be shown, [for example](http://stackoverflow.com/questions/27933159/how-to-draw-an-bufferedimage-to-a-jpanel/27933189#27933189) – MadProgrammer Apr 23 '15 at 03:01

1 Answers1

0

Lets say there are n files. you can achieve desired output by using the following piece of code

for(i=1;i<=n;i++){
Display("Sprite"+i+".png")
}
alekya reddy
  • 934
  • 1
  • 8
  • 14