Vercility wrote...
ImAndrew wrote...
Vercility wrote...
You're running a loop again
Your Dungeon1 constructor calls R1 which calls super( which is Dungeon1), which calls R1 etc.Super_Hippo wrote...
Try
private static World[] worldArr =
{
new D1_R1(),
new D1_R2(),
new D1_R3()
};public class Dungeon1 extends World
{
protected final static int WIDTH = 800;
protected final static int HEIGHT = 600;
protected final static int CELL_SIZE = 1;
protected static Hero hero = new Hero();
protected static World[] worldArr =
{
new D1_R1(),
new D1_R2(),
new D1_R3()
};
public Dungeon1(boolean _var)
{
super(WIDTH, HEIGHT, CELL_SIZE);
}
}danpost wrote...
Maybe you can get some pointers from my Door World Entry Demo scenario.public class Dungeon1 extends World
{
protected final static int WIDTH = 800;
protected final static int HEIGHT = 600;
protected final static int CELL_SIZE = 1;
protected static Hero hero = new Hero();
protected static World[] worldArr = new World[15];
public Dungeon1(boolean _var)
{
super(WIDTH, HEIGHT, CELL_SIZE);
if(!_var)
{
worldArr[0] = new D1_R1();
worldArr[1] = new D1_R2();
worldArr[2] = new D1_R3();
}
}
}public class Door extends Actor
{
World nextRoom;
Door(World _nextRoom)
{
nextRoom = _nextRoom;
}
public void act()
{
nextRoom(nextRoom);
}
public void nextRoom(World nextWorld)
{
if(getWorld().getObjects(Enemy.class).isEmpty())
{
Hero hero = (Hero)getOneIntersectingObject(Hero.class);
if(hero != null)
{
nextWorld.addObject(hero,100,150);
Greenfoot.setWorld(nextWorld);
}
}
}
}
