Slick Loading Animate GIF Image
This section I'll show you how to load Animate GIF. If you load an animate "
gif " image as the way you load a " png " image, the image will load perfectly,Here, we will use the Animation method.
Animation ani = new Animation();
We create a series of null image objects to hold all the images
//Creates a series of image objects
Image earth1 = null;
Image earth2= null;
Image earth3 = null;
Image earth4 = null;
Image earth5 = null;
Image earth6 = null;
Image earth7 = null;
Image earth8 = null;
Image earth9 = null;
Image earth10 = null;
(You can always store all the images into
an array)
We will load all the images the same way as we did from the previous section on
"Loading png Image."
earth1 = new Image("slickloadgifimage/images/10.gif");
earth2 = new Image("slickloadgifimage/images/9.gif");
earth3 = new Image("slickloadgifimage/images/8.gif");
earth4 = new Image("slickloadgifimage/images/7.gif");
earth5 = new Image("slickloadgifimage/images/6.gif");
earth6 = new Image("slickloadgifimage/images/5.gif");
earth7 = new Image("slickloadgifimage/images/4.gif");
earth8 = new Image("slickloadgifimage/images/3.gif");
earth9 = new Image("slickloadgifimage/images/2.gif");
earth10 = new Image("slickloadgifimage/images/1.gif");
Then, we add all the images into an animation frame
ani.addFrame(earth1, 500);
ani.addFrame(earth2, 500);
ani.addFrame(earth3, 500);
ani.addFrame(earth4, 500);
ani.addFrame(earth5, 500);
ani.addFrame(earth6, 500);
ani.addFrame(earth7, 500);
ani.addFrame(earth8, 500);
ani.addFrame(earth9, 500);
ani.addFrame(earth10, 500);
Finally, we will render the animation into the screen in the " render method "
ani.draw(50, 50);
It's a long process with a lot of works, but it's a perfectly working method to
load animate gif.