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/15

#
hmm all i can do now is say look at my senario ive got it working
davmac davmac

2012/4/15

#
but follow the link for greenfoor2.2
I just want to make this clear because people seem to keep forgetting: That link is not for Greenfoot 2.2.0, it is for the Greenfoot 2.2.0 beta which is not the same thing as the finished product. It is meant for people who are comfortable with using Greenfoot to have a sneak-peek at the new features and to see if they can spot any bugs. It is not meant for general use. Greenfoot 2.2.0 final will be out soon enough and that will be ready for general use. So: If you're downloading the Greenfoot 2.2.0 beta just so you can get the high score functionality, you're doing it wrong. Wait for Greenfoot 2.2.0!
martijn13039 martijn13039

2012/4/15

#
hey I got effrything working but there wilnot appear a hiscore look this is my code (er is no error but where is the hiscore) plz tell me what I need to do for see the hiscore public class BackGround extends World { private Counter counter; private concierge user; private ScoreBoard board; private Saver saver; private boolean gameOver; public BackGround() { super(700, 600, 1); prepare(); saver = new Saver(); } public void gameOver() { removeObject(user); saver.saveHighscore(counter.getValue() ); removeObject(counter); board = new ScoreBoard(600, 600); addObject(board, getWidth() /2, getHeight() /2); gameOver = true; { Saver saver = new Saver(); saver.saveHighscore(counter.getValue()); } if (counter.getValue() >= 100) { gameOver(); } }
SPower SPower

2012/4/15

#
You have to create the Saver and save the score BEFORE you create the scoreboard, or you won't get the user's score in the scoreboard.
martijn13039 martijn13039

2012/4/15

#
SPower can you tell me how the code wil be than because I try but it don´t work, the hiscore isn´t comming
SPower SPower

2012/4/15

#
sorry, I didn't see you were already doing it, I appologiz :)
martijn13039 martijn13039

2012/4/15

#
ooh You want to see the code ooh no problem if you seew i changed the like you say but there still is the same problem public class BackGround extends World { private Counter counter; private concierge user; private ScoreBoard board; private Saver saver; private boolean gameOver; public BackGround() { super(700, 600, 1); prepare(); saver = new Saver(); } public void gameOver() { { Saver saver = new Saver(); saver.saveHighscore(counter.getValue()); } removeObject(user); saver.saveHighscore(counter.getValue() ); removeObject(counter); board = new ScoreBoard(600, 600); addObject(board, getWidth() /2, getHeight() /2); gameOver = true; if (counter.getValue() >= 100) { gameOver(); } }
SPower SPower

2012/4/15

#
You maybe could change gameOver() to this:
public void gameOver()
{
    saver = new Saver();
    saver.saveHighscore(counter.getValue());
    removeObject(user);
    board = new ScoreBoard(600, 600);
    addObject(board, getWidth() /2, getHeight() /2);
    gameOver = true;
}
I hope this helps
danpost danpost

2012/4/15

#
martijn13039 wrote...
public void gameOver()
{
    {
        Saver saver = new Saver();
        saver.saveHighscore(counter.getValue());
        
       
    }
Comment out lines 3 through 8 above and try it then.
SPower SPower

2012/4/15

#
Remove the if statement from gameOver() and do what danpost said (and maybe what I said in my last comment) and it should work.
danpost danpost

2012/4/15

#
I thought that since the code was not well organized, that possibly martijn13039 had edited out some of the non-pertinent code and possibly the 'if' statement was in the act() method. Another thing that led me to that conclusion was the lack of the prepare() method. @martijn13039, when posting code, please use the code tag below the posting window Also, Ctrl-Shift-I your code before posting (that command properly indents your code and make it much easier for others, as well as yourself, to follow)
SPower SPower

2012/4/15

#
But if the if statement really is in the gameOver() method, and the condition is true, he'll get stack overflow.
martijn13039 martijn13039

2012/4/15

#
I have one more problem the game doesn´t stop and there wil no hiscore if I get 100 of more points (but er is no bug in the code I hope you wil help me again) I wil applogise for pusshing the code on the screem but I did't find the code tag
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)


public class BackGround extends World
{ 
private Counter counter; 
private concierge user;
private ScoreBoard board;    
private Saver saver;
private boolean gameOver;

    public BackGround()
    {    

        super(700, 600, 1); 

        prepare();
        saver = new Saver();
    }

    public void gameOver()  
    {
      Saver saver = new Saver();
      if(counter.getValue() >= 100) {
        gameOver();
    }
      saver.saveHighscore(counter.getValue());        
      removeObject(user);      
      board = new ScoreBoard(600, 600);     
      addObject(board, getWidth() /2, getHeight() /2);      
      gameOver = true;  
    }  
    

 private void prepare()
    {
        Counter Counter = new Counter();
        concierge concierge = new concierge(Counter);
        addObject(Counter, 54, 23);
        addObject (concierge, 120, 80);
        
    }
}
  
SPower SPower

2012/4/15

#
Change gameOver() to this:
public void gameOver()
{
   saver.saveHighscore(counter.getValue());
   removeObject(user);
   board = new ScoreBoard(600, 600);
   addObject(board, getWidth() /2, getHeight() /2);
   gameOver = true;
}
Just select this code en replace the ENTIRE gameOver() method that you have now with this code, this should work. And why do you have the gameOver boolean, it isn't used in any place I can see, so it's a waste of memory....
martijn13039 martijn13039

2012/4/15

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)


public class BackGround extends World
{ 
private Counter counter; 
private concierge user;
private ScoreBoard board;    
private Saver saver;
private boolean gameOver;

    public BackGround()
    {    

        super(700, 600, 1); 

        prepare();
        saver = new Saver();
    }

    public void gameOver() 

    { saver.saveHighscore(counter.getValue());  
      removeObject(user);  
      board = new ScoreBoard(600, 600);  
      addObject(board, getWidth() /2, getHeight() /2);  
      gameOver = true;  
    }  
    

 private void prepare()
    {
        Counter Counter = new Counter();
        concierge concierge = new concierge(Counter);
        addObject(Counter, 54, 23);
        addObject (concierge, 120, 80);
        
    }


    }
I have done what you say and delet but now if I get 100 points there wil happen nothing and the game don;t stop I hope you have anouther idea (and that boolean I need because if I don't have it er stay cannont find variable gameover stay or something like that) { Saver saver = new Saver(); if(counter.getValue() >= 100) { gameOver(); } new code (like you say)
There are more replies on the next page.
1
2
3
4