I am trying to have a .gif image as background (moving water). How can i get this to work?


1 | GifImage backgroundGif = new GifImage(filename); |
1 | setBackground(backgroundGif.getCurrentImage()); |
1 | GifImage backgroundGif = new GifImage(filename); |
1 | setBackground(backgroundGif.getCurrentImage()); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * This method is called by the Greenfoot system when the execution has * started. This method can be overridden to implement custom behavior when * the execution is started. */ @Override public void started() { gackgroundGif.resume(); } /** * This method is called by the Greenfoot system when the execution has * stopped. This method can be overridden to implement custom behavior when * the execution is stopped. */ @Override public void stopped() { backgroundGif.pause(); } |
1 | GifImage backgroundGif = new GifImage(filename); |
1 | setBackground(backgroundGif.getCurrentImage()); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Level3 here. * * @author (your name) * @version (a version number or a date) */ public class Level3 extends World { /** * Constructor for objects of class Level3. * */ public Level3() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super ( 600 , 600 , 1 ); } private void Animation(){ setBackground(backgroundGif.getCurrentImage()); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class water here. * * @author (your name) * @version (a version number or a date) */ public class backgroundGif extends Actor { GifImage backgroundGif = new GifImage( "c6orUp5K3WhdS.gif" ); /** * Act - do whatever the water wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { setImage( backgroundGif.getCurrentImage() ); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public class Level3 extends World { GifImage backgroundGif = new GifImage( "c6orUp5K3WhdS.gif" ); /** * Constructor for objects of class Level3. * */ public Level3() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super ( 600 , 600 , 1 ); Animation(); } public void Animation(){ setBackground(backgroundGif.getCurrentImage()); } } |
1 2 3 4 | public void act() { Animation(); } |
1 2 3 4 | public void act() { Animation(); } |