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?
1 2 3 4 | public Containergame2(){ setContainer(getRandomContainerType()); } |
1 2 3 4 5 6 7 8 | 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 ); } |