Time for action — loading and saving the high-score list

To load and save the state of a game, and so the high-score list, just copy some code from the game CometCrusher.

  1. Copy the following code from the LoadHighScore method of Chapter 4, Game #3, CometCrusher.
    Method LoadHighScore:Int ()
    Local state:String = LoadState()
    If state Then
    eng.scoreList.LoadFromString(state)
    Endif
    Return 0
    End
    
  2. Again, copy the following code from the SaveHighScore method from Chapter 4, Game #3, CometCrusher.
    Method SaveHighScore:Int ()
    Local hs:String = g.eng.scoreList.SaveToString()
    SaveState(hs)
    Return 0
    End
    

What just happened?

By reusing these two methods, you have saved yourself some valuable time for the future development of this game. It seems small, but when you reuse more and more, the advantage becomes visible.

Showing the high-score screen

When the player wants to see the high-score screen, the game needs to display the score layer with an updated score list.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.156.35