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

2017/9/17

How do i set a GIF as my background?

Recorsi Recorsi

2017/9/17

#
Hello Community, im a beginner with greenfoot and im making a simple game, but now i want to set my background(The world) to a gif i downloaded. i tried following this this tutorial but he did it with an actor class. My background doesnt have an act method and creating one didnt really help. how can i set a gif as my background?
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Spielfeld here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Spielfeld extends World
{
    GifImage background = new GifImage("background.gif");
    /**
     * Constructor for objects of class Spielfeld.
     * 
     */
    public Spielfeld()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(640, 480, 1); 
    }
    public void act()
    { 
        setImage( background.getCurrentImage() );
        
    }
}
danpost danpost

2017/9/17

#
The 'setImage' method is an Actor class method. The World class uses a 'setBackground' method for setting its image.
Recorsi Recorsi

2017/9/17

#
danpost wrote...
The 'setImage' method is an Actor class method. The World class uses a 'setBackground' method for setting its image.
Thank you really much :)
You need to login to post a reply.