In the constructor Containergame2 I want to get all the objects of the class MainContainer.
But getWorld keeps returning null.
the constructor:
The method getRandomContainerType:
So what I want is that in the constructor it gives me a list with all the objects of the class MainContainer.
What am I doing wrong?
public Containergame2(){ setContainer(getRandomContainerType()); }
public int getRandomContainerType(){ MiniGame2 world = (MiniGame2) getWorld(); System.out.println(world); //returns null System.out.println(world.getObjects(MainContainer.class)); // returns null return Greenfoot.getRandomNumber(4); }