0

I am new to programming and we have an assignment about making a Greenfoot game. now I am trying to set some colors to MyWorld but having some problems. My code in MyWorld file is

   public MyWorld()
{    
    // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
    super(600, 400, 1); 
    GreenfootImage bg = new GreenfootImage(600, 400);
    bg.setColor(new Color(0, 0, 250, 9));
    setImage(bg);

}

and it is returning an error

cannot find symbol - method setImage(greenfoot.GreenfootImage)

The same code on one of the Actor classes working normally.

    public BgCells(){
    GreenfootImage bgBig = new GreenfootImage(200, 200);
    bgBig.setColor(new Color(0, 0, 250));
    setImage(bgBig);
}
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433

1 Answers1

0

The method in Actor is called setImage, but the similar method in World is called setBackground. A bit confusing, I know.

Note also that setColor doesn't do anything by itself, it just sets the drawing colour. If you want to fill the image with that colour, call bgBig.fill after calling setColor.

Neil Brown
  • 3,558
  • 1
  • 27
  • 36