This site requires JavaScript, please enable it in your browser!
Greenfoot back
emfish15
emfish15 wrote ...

2020/3/18

Need Help- Code will not compile

emfish15 emfish15

2020/3/18

#
Directions: a method calledactthat takes no parameters and returns nothing. This method shouldcheck to see if the ā€œnā€ key has been pressed. If that key has been pressedandthere areno Lobstrosities in the world, then the scoreboard should bereset for a new game, a newLobstrosity should be added to the world in the center horizontally and between 40 and 240for a y-location, and a new player should be centered at the bottom of the world. My code: public void act() { reduceStrength--; if (Greenfoot.isKeyDown("N") && (Lobstrosity<=0)) { addObject(new Lobstrosity(300,Greenfoot.getRandomNumber(240)+40)); setRotation(90); addObject(new Player(310,368)); } } The error is when I added the Object. It says the constructor cannot be applied to given types. Anyone know how to fix this?
danpost danpost

2020/3/18

#
I believe that the first addObject line should be:
addObject(new Lobsterosity(), 300, Greenfoot.getRandomNumber(240)+40);
You need to login to post a reply.