Question

So in my game, you want to make the potato as big as possible. The first time you play it, the highscores work fine,giving you a highscore and saving it. The problem is that whenever you play the game, the highscore is always reset to your current score, which means that even if you get a lower score then your previous highscore, it saves your current score as the highscore. my code looks like this:

var savedstuff:SharedObject = SharedObject.getLocal("myStuff");

if (savedstuff.data.bestScore = 0) {
     savedstuff.data.bestScore = 1
}


bigness.text = finish.toString();

if (finish > savedstuff.data.bestScore){
    savedstuff.data.bestScore = finish;
}
best.text = savedstuff.data.bestScore.toString();
savedstuff.flush();

where bigness is a textbox displaying your current score, best is a textbox displaying your highscore and bestScore is where the best score is stored. I have the line "if (finish > savedstuff.dada.bestScore)" which should make the overwrite only occur if you get a higher score, but it seems to just ignore that line. my game is here http://www.kongregate.com/games/pwnedcat/grow-a-potato

any help is appreciated. I just started flash so I really don't know anything. :(

Was it helpful?

Solution

Check the condition, it should be

savedstuff.data.bestScore == 0

Instead of

savedstuff.data.bestScore = 0
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top