Esempio n. 1
0
 /**
  * Return the world's background image. The image may be used to draw onto the world's background.
  *
  * @return The background image
  */
 public GreenfootImage getBackground() {
   if (backgroundImage == null) {
     backgroundImage = new GreenfootImage(getWidthInPixels(), getHeightInPixels());
     backgroundImage.setColor(DEFAULT_BACKGROUND_COLOR);
     backgroundImage.fill();
     backgroundIsClassImage = false;
   } else if (backgroundIsClassImage) {
     // Make the image a copy of the original to avoid modifications
     // to the original.
     backgroundImage = backgroundImage.getCopyOnWriteClone();
     backgroundIsClassImage = false;
   }
   return backgroundImage;
 }