Hello everyone ,
I'm trying to get my score in the game's end to be saved , but without using the userInfo, only when stop the game without reset , as this would make the score back to zero, but it is always to zero without being saved.
In my world , I have this:
To get my highScore and insert it in the start menu, i have this:
And to save my score at the end of the game, I call for saveScore method in the snake.
Someone can help me?
1 2 3 4 5 6 7 8 9 10 11 12 13 | public void saveScore() { ScoreCounter score = getScore(); if (score.getPreviousScore() > highScore) { highScore = score.getPreviousScore(); } } public int highScore() { return highScore; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | public void bestScore() { SnakeWorld world = (SnakeWorld) getWorld(); int score = world.highScore(); if (highScores[ 0 ] <= score) { highScores[ 0 ] = score; } else { if (highScores[ 1 ] <= score) { highScores[ 1 ] = score; } else { if (highScores[ 2 ] <= score) { highScores[ 2 ] = score; } } } } |