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

2012/5/28

Scoreboard Counter

fergo2012 fergo2012

2012/5/28

#
Hey, I'm creating a Space Invaders game and at the end of the game I want to have a Scoreboard displaying the User's score. So far I have the Scoreboard appearing but my issue is making the value that appears on the Scoreboard the same as the User's score. Currently everytime the value is 100. Help on how to get the corresponding value appear would be great!
davmac davmac

2012/5/28

#
You need to pass the Scoreboard the correct score (probably to the constructor) and then display that. Add an 'int score' parameter to your Scoreboard constructor, if you don't already have one.
danpost danpost

2012/5/28

#
You could let the new Scoreboard object know what score to display when you create it -- new Scoreboard(score). Just need to create a constructor that accepts the int value. -- public Scoreboard(int finalScore). If the score of '100' is hard-coded in, just replace it with 'finalScore' (if it is in the constructor itself). If there is a seperate method for creating the image of the new Scoreboard object, then finalScore will have to be passed to that method; either by a parameter to the method, or by saving the finalScore in an instance variable, so the method can access it.
You need to login to post a reply.