I would like to put in an animated gif file to my world class background. What is the code that will do that? Thank you -


import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Space is the setting for Spaceship scenario. * This is a place where Meteors, Satelites, and FuelCells float around. * * @author Michael V. * @version 1.0 */ public class Space extends World { private int fuel; private int score; /** * Constructor: Set up the staring objects. */ public Space() { super(780, 360, 1); prepare(); setPaintOrder(Border.class); score = 0; fuel = 2000; showFuel(); //getCurrentImage(); } /** * Create new floating objects at random intervals. */ public void act() { if (Greenfoot.getRandomNumber(100) < 3) { addObject(new FuelCell(), 779, Greenfoot.getRandomNumber(360)); } if (Greenfoot.getRandomNumber(100) < 3) { addObject(new Surface(), 779, 0); } if (Greenfoot.getRandomNumber(100) < 3) { addObject(new Surface(), 779, 359); } if (Greenfoot.getRandomNumber(100) < 1) { addObject(new Meteor(), 779, Greenfoot.getRandomNumber(360)); } if (Greenfoot.getRandomNumber(100) < .05) { addObject(new Satelite(), 779, Greenfoot.getRandomNumber(360)); } countFuel(); } public void addScore(int points) { score = score + points; showText("Score: " + score, 80, 25); } public void addFuel(int bonus) { fuel = fuel + bonus; showText("Fuel: " + fuel, 700, 25); } private void countFuel() { fuel--; showFuel(); if (fuel == 0) { showEndMessage(); Greenfoot.stop(); } } private void showFuel() { showText("Fuel: " + fuel, 700, 25); } /** * Prepare the world for the start of the program. In this case: Spawn * a Spaceship and the moons surface at the edge of screen. */ private void prepare() { Spaceship spaceship = new Spaceship(); addObject(spaceship, 103, 179); Surface surface = new Surface(); addObject(surface, 126, 1); Surface surface2 = new Surface(); addObject(surface2, 342, 5); Surface surface3 = new Surface(); addObject(surface3, 589, 2); Surface surface4 = new Surface(); addObject(surface4, 695, 5); Surface surface5 = new Surface(); addObject(surface5, 114, 359); Surface surface6 = new Surface(); Surface surface7 = new Surface(); addObject(surface7, 295, 353); Surface surface8 = new Surface(); Surface surface9 = new Surface(); Surface surface10 = new Surface(); addObject(surface10, 480, 358); Surface surface11 = new Surface(); addObject(surface11, 596, 359); Surface surface12 = new Surface(); addObject(surface12, 740, 354); Border border = new Border(); addObject(border, 0, 180); Border border2 = new Border(); addObject(border2, 770,180); setPaintOrder(Border.class); } private void showEndMessage() { showText("Times up - you win!", 390, 150); showText("Your final score was: " + score + "points!", 390, 170); } }
private GifImage animation = new GifImage("<< gif filename >>");
setBackground(animation.getCurrentImage());