Can anybody tell me where I'm going wrong with my high score events? I've followed a couple of tutorials but I'm having issues as it sets the high score but then after a few times of playing, it's like it forgets it and so resets. So, for instance, if my high score was 10, it would set this and I'd play a few games and at the end of the third or fourth game, if I'd only got 5 points it would set the high score to 5 rather than remembering it's 10.
I've used the persist behaviour on the text objects but this hasn't made a difference.
Been stuck with this a while so would be great to get some advice on it.
Develop games in your browser. Powerful, performant & highly capable.
You're saving the current score to local storage every time on player destroyed. You want to do so only if the current score is the highest score.
I'm still not having any luck with this. What I've done is:
deleted 'on player destroyed', so the event is now score > high score - set item 'score' to score & set high score to score.
I just tested this but it didn't work. For some reason the game remembers the high score correctly for around 3 games then after this it just resets for some reason, any ideas where I'm going wrong?
Resets to what? Do you have another event writing to the score key somewhere?
Turns out elsewhere in the events on player destroyed I had it setting score.
Thanks for this - I wouldn't have thought to check if you hadn't have said that.