Dayuyu wrote...
at Q world the error is lastworld = world...the word world cannot find symbol..
java.lang.NullPointerException: The given world cannot be null. at greenfoot.Greenfoot.setWorld(Greenfoot.java:70) at a.act(a.java:23) at greenfoot.core.Simulation.actActor(Simulation.java:594) at greenfoot.core.Simulation.runOneLoop(Simulation.java:552) at greenfoot.core.Simulation.runContent(Simulation.java:215) at greenfoot.core.Simulation.run(Simulation.java:205) java.lang.NullPointerException: The given world cannot be null. at greenfoot.Greenfoot.setWorld(Greenfoot.java:70) at b.act(b.java:24) at greenfoot.core.Simulation.actActor(Simulation.java:594) at greenfoot.core.Simulation.runOneLoop(Simulation.java:552) at greenfoot.core.Simulation.runContent(Simulation.java:215) at greenfoot.core.Simulation.run(Simulation.java:205) java.lang.NullPointerException: The given world cannot be null. at greenfoot.Greenfoot.setWorld(Greenfoot.java:70) at a.act(a.java:23) at greenfoot.core.Simulation.actActor(Simulation.java:594) at greenfoot.core.Simulation.runOneLoop(Simulation.java:552) at greenfoot.core.Simulation.runContent(Simulation.java:215) at greenfoot.core.Simulation.run(Simulation.java:205)
private World lastWorld;
public void act()
{
// Add your action code here.
if (Greenfoot.mouseClicked(this)) {
win alert_win = new win();
getWorld().addObject(alert_win, 370, 300);
Greenfoot.delay(100);
Greenfoot.setWorld(lastWorld);
}
}
} private World lastWorld;
public void act()
{
// Add your action code here.
if (Greenfoot.mouseClicked(this)) {
loose alert_loose = new loose();
getWorld().addObject(alert_loose, 370, 300);
Greenfoot.delay(100);
Greenfoot.setWorld(lastWorld);
}
}
}Q qWorld = (Q)getWorld(); // get reference to Q world object Greenfoot.setWorld(qWorld.getLastWorld());
public World getLastWorld()
{
return lastWorld;
}Q qWorld = (Q)getWorld(); GameWorld gWorld = (GameWorld)qWorld.getLastWorld(); // replace 'GameWorld' with name of game world class Counter scoreCounter = gWorld.getScoreCounter();
public void checkKey()
{
if(isTouching(tree.class))
{
move(-4);
}