import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Play here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Play extends Actor
{
/**
* Act - do whatever the Play wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(Greenfoot.mouseClicked(this)){
World World = getWorld();
World.removeObject(this);
GameWorld.loadLevel();}}}
This keeps giving me: non static method loadLevel cannot be referenced from a static context. First of all, i don't really understand static code and how would i fix it?. Here is my copy of the world:import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class GameWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class GameWorld extends World
{
/**
* Constructor for objects of class GameWorld.
*
*/
public GameWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
setBackground("title.png");
addObject(new Play (),100,300);
addObject(new Crosshair(),100,100);
}
public void loadLevel(){
setBackground("start.png");
}
}
Help Appreciated