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

2012/4/14

Can somebody explain me how I can make a hiscore

1
2
3
4
-nic- -nic-

2012/4/14

#
????....Damm
danpost danpost

2012/4/14

#
-nic- wrote...
????....Damm
LOL! What was that for???
martijn13039 martijn13039

2012/4/14

#
thx for helping but the problem stay, I make the code like you say danpost but there stil is a red square on pirvate "PlayerData" playerl; ("...." is red square) I hope now you no what the problem is import greenfoot.*; public class Saver { private PlayerData player; public Saver() { if (PlayerData.isStorageAvailable() ) { if (PlayerData.getMyData() != null) { player = PlayerData.getMyData(); } } } public void saveHighscore(int score) { if (PlayerData.isStorageAvailable() ) { if (PlayerData !=null) { if (score > PlayerData.getScore() ) { PlayerData.setScore(score); PlayerData.sore(); } } } } }
danpost danpost

2012/4/14

#
I wish I could help, but I have not yet downloaded 2.2.0 beta. I am waiting for 2.2.0 to be available for USB flash drive.
SPower SPower

2012/4/14

#
Why do you do: PlayerData.setScore(score); PlayerData.store(); Do: player.setScore(score); player.store(); You can't store or set the score for the class PlayerSata, you have to do that with your instance variable.
ttamasu ttamasu

2012/4/14

#
Have you tried using the menu item Edit | Import Classes... and select ScoreBoard. It looks like it has the complete code necessary for posting a score board but if you want to write your own.... I guess its good experience -- Takashi
martijn13039 martijn13039

2012/4/14

#
the problem stay cannot find symbol class scorenboard
davmac davmac

2012/4/15

#
martijn13039, what version of Greenfoot are you actually using?
martijn13039 martijn13039

2012/4/15

#
davmac sorry for my lost respont but I have version 2.1.2 and maby thats the problem but where can I download the new version of greenfoot than I hope you can help me.
-nic- -nic-

2012/4/15

#
danpost wrote...
-nic- wrote...
????....Damm
LOL! What was that for???
well i was just abit anoyed i dident spot that oh well:)
-nic- -nic-

2012/4/15

#
http://www.greenfoot.org/topics/1084 link for 2.2 dowmload:)
martijn13039 martijn13039

2012/4/15

#
Sorry for my stupid action and the first code works great but I don´t understand the last code. I make a hiscore but I don´t know what I need than plz giff me some advice
-nic- -nic-

2012/4/15

#
i cant really help you here sorry:(
martijn13039 martijn13039

2012/4/15

#
than I mean from this text I don´t understand because if I put the code in there stay unspected user plz help Now we need to create a saver. Go to Ground and scroll down to the gameOver() method, and add these lines at the bottom of it: Saver saver = new Saver(); saver.saveHighscore(counter.getValue()); These lines simply create a save and let that saver save the current score of the counter. All we need to do now is create a score board, so you can see your score and other’s scores. Import the class ScoreBoard, by going to edit--->import class--->ScoreBoard. Change gameOver() in Ground to: removeObject(user); Saver saver = new Saver(); saver.saveHighscore(counter.getValue()); ScoreBoard board = new ScoreBoard(600, 350); addObject(board, getWidth() /2, getHeight() /2); This creates a scoreboard and puts it into the world.
-nic- -nic-

2012/4/15

#
but follow the link for greenfoor2.2 here
There are more replies on the next page.
1
2
3
4