My game has a score on the screen that updates correctly. But I can’t figure out how to get a high score to work. I would like for the high score number to remain on the screen even if the game ends, and a player starts a new game. Attached is an image of my code. In my code, the high score always shows 0. Thank you for your help.
There isn’t a lot of code, but I can think in some possible problems and tips:
-I can’t see how do you get the Vaiable(playerScore), sice it’s a scene variable, and you compute the GlobalVariable(highScore) with it at the beginning of the scene… The scene variables are reset at the beginning of the scene (perhaps you read it from a saved file?). Maybe you should compute GlobalVariable(highScore) at the moment the player loses and you get a non-reset Variable(playerScore).
-About condition “Layer ‘Game Over’ is visible”, do you need to check it and set the variable every frame?. Because, otherway, you could add a condition “Trigger once”, to set the variable only the first time the layer is visible
-I think it’s a bad idea to change a integer variable (highScore) to a string one. Since you can put the string "High score: " wherever you want, you don’t need to save the text in the variable, but use it as you did at the beginning ("Some string "+GlobalVariableString(integer)). As you used chained strings before, I think you have your reasons to don’t do it, but note that you can’t use the condition: playerScore > highScore after that, since highScore isn’t a number
Thank you for your help and suggestions. I finally got it working.