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

2017/5/2

.gif word background

skitlesas skitlesas

2017/5/2

#
Hello I need help how set Word background .gif. When i trying Set image.. my background don't moving...
danpost danpost

2017/5/2

#
skitlesas wrote...
Hello I need help how set Word background .gif. When i trying Set image.. my background don't moving...
Please show the code you are using. Seeing the actual goes a long way to understanding the issue and what may be going on. Showing the entire class helps even more as you will not have to continually post bits and pieces of it until, finally, there is enough to help.
skitlesas skitlesas

2017/5/2

#
import greenfoot.World;
import greenfoot.Actor;
import greenfoot.GreenfootImage;
import greenfoot.Color;
import greenfoot.*;

public class Zaidimas extends World
{
    public static int SIZEX = 700;
    public static int SIZEY = 600;
    
    public static int BRICKSPACING = 10;
    public static int BRICKLEFTBORDER = 30;
    public static int BRICKRIGHTBORDER = 30;
    public static int BRICKWIDTH = 30;
    public static int BRICKHEIGHT = 15;
    public static int BRICKTOPBORDER = 10;
    private boolean gameStarted = false; 
    
    public void act()
    {
      while (!gameStarted)
      {
        if (Greenfoot.isKeyDown("space"))
        {
            gameStarted = true;
        }
      }
    }
    
    public Zaidimas() {
        super(SIZEX, SIZEY, 1);
        scenario1();
    } 
        
    public void scenario1()
    {
        //kamuoliukas
        addObject(new Kamuoliukas(), 350, 559);
        //pirma eile
        addObject(new Plyta(), 46, 22);
        addObject(new Plyta(), 96, 22);
        addObject(new Plyta(), 146, 22);
        addObject(new Plyta(), 196, 22);
        addObject(new Plyta(), 246, 22);
        addObject(new Plyta(), 296, 22);
        addObject(new Plyta(), 346, 22);
        addObject(new Plyta(), 396, 22);
        addObject(new Plyta(), 446, 22);
        addObject(new Plyta(), 496, 22);
        addObject(new Plyta(), 546, 22);
        addObject(new Plyta(), 596, 22);
        addObject(new Plyta(), 646, 22);
        //antra eile
        addObject(new Plyta(), 46, 53);
        addObject(new Plyta(), 96, 53);
        addObject(new Plyta(), 146, 53);
        addObject(new Plyta(), 196, 53);
        addObject(new Plyta(), 246, 53);
        addObject(new Plyta(), 296, 53);
        addObject(new Plyta(), 346, 53);
        addObject(new Plyta(), 396, 53);
        addObject(new Plyta(), 446, 53);
        addObject(new Plyta(), 496, 53);
        addObject(new Plyta(), 546, 53);
        addObject(new Plyta(), 596, 53);
        addObject(new Plyta(), 646, 53);
        //trecia eile
        addObject(new Plyta(), 46, 84);
        addObject(new Plyta(), 96, 84);
        addObject(new Plyta(), 146, 84);
        addObject(new Plyta(), 196, 84);
        addObject(new Plyta(), 246, 84);
        addObject(new Plyta(), 296, 84);
        addObject(new Plyta(), 346, 84);
        addObject(new Plyta(), 396, 84);
        addObject(new Plyta(), 446, 84);
        addObject(new Plyta(), 496, 84);
        addObject(new Plyta(), 546, 84);
        addObject(new Plyta(), 596, 84);
        addObject(new Plyta(), 646, 84);
        //ketvirta eile
        addObject(new Plyta(), 46, 114);
        addObject(new Plyta(), 96, 114);
        addObject(new Plyta(), 146, 114);
        addObject(new Plyta(), 196, 114);
        addObject(new Plyta(), 246, 114);
        addObject(new Plyta(), 296, 114);
        addObject(new Plyta(), 346, 114);
        addObject(new Plyta(), 396, 114);
        addObject(new Plyta(), 446, 114);
        addObject(new Plyta(), 496, 114);
        addObject(new Plyta(), 546, 114);
        addObject(new Plyta(), 596, 114);
        addObject(new Plyta(), 646, 114);
        //Spygliai
        addObject(new spygliai(), 17, 666);
        addObject(new spygliai(), 52, 666);
        addObject(new spygliai(), 88, 666);
        addObject(new spygliai(), 124, 666);
        addObject(new spygliai(), 160, 666);
        addObject(new spygliai(), 197, 666);
        addObject(new spygliai(), 233, 666);
        addObject(new spygliai(), 269, 666);
        addObject(new spygliai(), 305, 666);
        addObject(new spygliai(), 340, 666);
        addObject(new spygliai(), 376, 666);
        addObject(new spygliai(), 412, 666);
        addObject(new spygliai(), 448, 666);
        addObject(new spygliai(), 483, 666);
        addObject(new spygliai(), 518, 666);
        addObject(new spygliai(), 553, 666);
        addObject(new spygliai(), 589, 666);
        addObject(new spygliai(), 624, 666);
        addObject(new spygliai(), 659, 666);
        addObject(new spygliai(), 695, 666);
        //Lenta
        addObject(new Lenta(), 350, SIZEY - 20); 
    }
}
danpost danpost

2017/5/2

#
Change the act method to this:
public void act()
{
    if (!gameStarted && "space".equals(Greenfoot.getKey())
    {
        gameStarted = true;
    }
}
EDIT: I do not see any code related to the issue at all (no 'setBackground' method calls anywhere). Setting a default image for the class only sets the initial background of a world created from the class. I have an Animation class that may help out. You will probably need the GifImage class as well to extract the GreenfootImage objects from the 'gif'. As well, there may be a misunderstanding here. What you want appears to be that the background image of the world it to be animated. As such, all images of the 'gif' need to be the same size. Unfortunately, I cannot currently help in this matter (will be off for about 10 hrs.).
You need to login to post a reply.