I'm trying to create objects the player can interact with to bring them to another world. These door objects act like this.
The first if statement checks if the player is interacting in one world, while the other one checks the same thing but in another world.
When I add one of these objects into the world, it works like a charm. However, when I place two instances of the object, the second one I placed doesn't work, while the first one does. If I flip the order, the first one instantiated is still the only one that works
To place them I just use addObject
Any help would be appreciated. Thanks.
int WorldNumber;
public Door(int WorldNumber){
this.WorldNumber = WorldNumber;
}
public void act()
{
if (getOneIntersectingObject(player.class) != null && Greenfoot.isKeyDown("enter") && getWorld() instanceof WalkingWorld && !isPressing) {
Greenfoot.setWorld(new InsideArea(WorldNumber));
}
if (getOneIntersectingObject(player.class) != null && Greenfoot.isKeyDown("enter") && getWorld() instanceof InsideArea && !isPressing) {
Greenfoot.setWorld(new WalkingWorld(WalkingWorld.CurrentWorld));
}
isPressing();
}

