Here is my code:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Start here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Start extends World
{
/**
* Constructor for objects of class Start.
*
*/
public Start()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(700, 600, 1);
GreenfootImage ghosttown = new GreenfootImage("Ghost Town.jpg");
ghosttown.scale(getWidth(), getHeight());
setBackground(ghosttown);
GameStartCard start= new GameStartCard();
addObject(start, 350, 300);
if (Greenfoot.isKeyDown("space")) {
Greenfoot.setWorld(new Background());
}
}
}
I want greenfoot to load a new world if the user presses space, as you can see in the code. But this is not working. Can you help me fix this?
