1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public void act() { //get a randint and compare to var with value 20 if (Greenfoot.getRandomNumber( 1500 ) < FallingActorSpawnRate) { //get another randint 0-3 spawn actor depending on value switch (Greenfoot.getRandomNumber( 3 )) { case 1 : //the parameters passed here are seen as variables not classes //these classes are subclasses of FallingActors which is a subclass of actor spawnActor(Distractions); case 2 : spawnActor(Hints); case 3 : spawnActor(Questions); default : break ; } } } //take class as a parameter public void spawnActor(Class c) { //errors are where ever c is written as it doesnt see it as a parameter //instead it treats it as a normal class //create new actor c newActor = new c(); c.setSpeed(FallingActorSpeed); addObject(c, Greenfoot.getRandomNumber(getWidth()- 20 )+ 10 , - 30 ); } |

