I want to code an Explosion on death, which depending on the world youre in restarts it. But an error message always show up marking the "this.getWorld().getClass() == Level3.class" line, when th eplayer dies. Any help?
private int counter = 0; public void act() { explode(); counter = counter + 1; if(counter>24 && this.getWorld().getClass() == Level1.class) { this.getWorld().removeObject(this); Greenfoot.setWorld(new Level1()); } if(counter>24 && this.getWorld().getClass() == Level2.class) { this.getWorld().removeObject(this); Greenfoot.setWorld(new Level2()); } if(counter>24 && this.getWorld().getClass() == Level3.class) { this.getWorld().removeObject(this); Greenfoot.setWorld(new Level3()); } }