When i swap between worlds, i just have it swap to another world with the character already placed in it, how do i get the character to swap to another world, and still have the same health and same value for all the other variables.
private Character character;
public World2() {
this(new Character());
}
public World2(Character charctr) {
character = charctr;
// here/now you can use charctr/character however you wanted and it will have the values specified
// in this case the ones from the first world
}Character character = new Character(); // then when you switch worlds to World2 you would do: Greenfoot.setWorld(new World2(character));
private Character character;
public World2() {
this(new Character());
}
public World2(Character charctr) {
character = charctr;
} Character character = new character();
if (getWorld() instanceof world1)
{
if(isTouching(Character.class))
{
Greenfoot.setWorld(new world2(character));
}
}Character character = (Character) getOneIntersectingObject(Character.class);