This works.
This doesn't. Why?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class StartButton here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class StartButton extends Actor
{
/**
* Act - do whatever the StartButton wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
Backdrop backdrop = (Backdrop)getWorld();
backdrop.prepare();
}
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class StartButton here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class StartButton extends Actor
{
Backdrop backdrop = (Backdrop)getWorld();
/**
* Act - do whatever the StartButton wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
backdrop.prepare();
}
}
