i'm having trouble transitioning one world at a time. if you can help, please do. here's the code i'm having trouble with.
private void hitEnemy() {
Cell cell = (Cell) getOneObjectAtOffset(0, 0, Cell.class);
if (cell != null) {
cell.setHealth(-1000);
cell.move(40);
if (cell.health <=0)
{
mark();
win();
getWorld().removeObject(cell);
Greenfoot.playSound("gohanyelling.wav");
if (timer.millisElapsed() > 4000)
{
if (level == 1) {
level = 2;
Greenfoot.setWorld(new level2());
Greenfoot.delay(30);
mark();
getWorld().removeObject(this);
}
if (level == 2) {
level = 3;
Greenfoot.setWorld(new level3());
Greenfoot.delay(30);
mark();
getWorld().removeObject(this);
}
}
}
}
}

