This site requires JavaScript, please enable it in your browser!
Greenfoot back
frequency
frequency wrote ...

2018/2/26

Greenfoot wont load full GIF image as background

frequency frequency

2018/2/26

#
Hello, I want to add as background of a world a gif. The world is named CreditWorld and here is its code
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class CreditWorld here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class CreditWorld extends World
{
    GifImage creditgif = new GifImage("credit.gif");
    
    
    /**
     * Constructor for objects of class CreditWorld.
     * 
     */
    public CreditWorld()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(1000, 600, 1); 
        backgif();
     }
     
     void backgif()
    {
         setBackground(creditgif.getCurrentImage());
         
    }
    
}
    
Thanks.It will only load the 1st frame of the gif!
Super_Hippo Super_Hippo

2018/2/26

#
You need to add an act method and call the backgif method there.
frequency frequency

2018/2/26

#
Done! Thanks!
You need to login to post a reply.