how can you make it so that when an actor gets to a place in the world it goes to the next world


// variables defining the area where the actor must be to switch worlds int hitboxMinX, hitboxMaxX, hitboxMinY, hitboxMaxY; // code to change worlds (after the movement code) if (getX() >= hitboxMinX && getX() <= hitboxMaxX && getY() >= hitboxMinY && getY() <= hitboxMaxY) Greenfoot.setWorld(new World2());