SallySanban wrote...
I would put them in the parameter of the door. I just removed them because it didn't work at the time.
Alleyway4 aw4 = new Alleyway4(type, lastType); aw4.removeObjects(inventory.collectedObjects);
Alleyway4 aw4 = new Alleyway4(type, lastType); aw4.removeObjects(inventory.collectedObjects);
removeObjects(inventory.collectedObject);
removeObjects(inventory.collectedObject);
// after the background image array
private static World[] worlds = new World[bgImages.length];
// new world constructor for saving worlds
public Alleyway4(World world)
{
super(1, 1, 1, false);
for (Object obj : world.getObjects())
{
Actor actor = (Actor)obj;
addObject(actor, actor.getX(), actor.getY());
}
}
// modify your 'changeBackground' method
public void changeBackground(int change)
{
worlds[type] = new Alleyway4(this);
Greenfoot.setWorld(new Alleyway4(type+change, type);
}
// do this with the switch in the Allyway4(int, int) constructor
if (worlds[type] == null)
{
switch....
}
else
{
for (Object obj : worlds[type].getObjects())
{
Actor actor = (Actor) obj;
addObject(actor, actor.getX(), actor.getY());
}
}public Alleyway4(int worldType, int lastWorldType)
{
//etc.
DiamondKey diamondkey = new DiamondKey();
switch(type)
{
//etc.
case 11: if(!inventory.inventoryObjects.contains(diamondkey)){addObject(diamondkey, 100, 100);}; addObject(new StudentDoor(diamondkey), 505, 195); break;
//etc.
}
}