In my world I creates a number of objects randomly in the world. I am doing this for 2 different Actors in different ways, so i though a method would simplify things. However I am having trouble passing an actor as a parameter.
Here is the method I have so far.
Here I call the method.
1 2 3 4 5 6 7 8 9 | public void createThingsRandLocal( int num, Actor object) { for ( int i = 0 ; i < num; i = i + 1 ) { int xSpawn = Greenfoot.getRandomNumber( 600 ); int ySpawn = Greenfoot.getRandomNumber( 400 ); addObject(object, xSpawn, ySpawn); } } |
1 | createThingsRandLocal( 100 , Food) |