I already know the code to switch to another world. I have an object that when the character touches it, it swaps to another world. But i don't want a lode of objects to switch worlds, one for each world. so i tried this
world World = (world) getWorld();
if(getWorld() == world)
{
if(isTouching(hero.class))
{
Greenfoot.setWorld(new world2());
}
}
for each world inside the object, and it compiled, but when it tried running it gave me an error, so i tried this
if(getWorld() == (new world()))
{
if(isTouching(hero.class))
{
Greenfoot.setWorld(new world2());
}
}
and it compiled but it didn't do anything
is there any code i can use that works