Created
March 5, 2019 12:04
-
-
Save EliteIntegrity/15c0b6aa5e5bb498cc868cfa7e117e1a to your computer and use it in GitHub Desktop.
Add this code to the end of the pause function to save the players new high score if one was achieved in the current play session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val prefs = context.getSharedPreferences( | |
"Kotlin Invaders", | |
Context.MODE_PRIVATE) | |
val oldHighScore = prefs.getInt("highScore", 0) | |
if(highScore > oldHighScore) { | |
val editor = prefs.edit() | |
editor.putInt( | |
"highScore", highScore) | |
editor.apply() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment