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

2014/3/28

problem with high scores and 2 worlds

AIMrOrange AIMrOrange

2014/3/28

#
Hello guys, I have a problem: my scenario has 2 worlds, a Startscreen and a Playworld. I want to have a high score list, so i need to save the score from the Playworld and load it in the Startscreen to be able to show the Playernames and the Scores... Is there a posibility to get just an integer from one world to another? thanks in advance, Max
danpost danpost

2014/3/28

#
Basically, what you want (this is just an example, and not exactly what you would use) is this:
// in Playworld
    // field
Startscreen ss; // pre-set with a Startscreen object
    // code
ss.setScore(getPlayer().getScoreCounter().getValue());
Greenfoot.setWorld(ss);
AIMrOrange AIMrOrange

2014/3/28

#
Thank you, i already got the information about that, but i have still a problem. I have a condition, if its true the "ss.setScore()" etc is executed and works. Its just doesnt only store the new score, it overwrites every score, no matter if you are better or worse. Here my Code:
public void setScore(int x)
    {
        neueScore = x;
        if(neueScore>myInfo.getScore())
        {
            myInfo.setScore(neueScore);
            highscore = myInfo.getScore();
        }
    }
//highscore ist der anzeigetext
AIMrOrange AIMrOrange

2014/3/28

#
ok i just tested something, the "setScore(x)" method works fine... there must be a problem in the playworld
AIMrOrange AIMrOrange

2014/3/28

#
and just btw, how the fuck can i update a already uploaded scenario? (like patching)^^
danpost danpost

2014/3/29

#
Just re-upload it using the same name (which you should not have to mess with).
AIMrOrange AIMrOrange

2014/3/29

#
ah thank you very much, havent thought it`s simple as that^^
You need to login to post a reply.