Time for action — setting up the high score list

We can set up the high score as follows:

  1. Inside the game class, create a new method called CreateHighScoreList.
    Method CreateHighScoreList:Int ()
    
  2. The list has a title; guess which one? Create a text object for it that is set to the layerScore layer.
    Local txtTitleHightScore:ftObject = eng.CreateText(font1,"H I G H S C O R E S",eng.canvasWidth/2,70,1)
    txtTitleHightScore.SetLayer(layerScore)
    
  3. Now, start a FOR loop for 10 entries.
    For Local y:Int = 1 To 10
    
  4. Each score entry will have a number on the left, indicating the rank inside the list.
    Local txtScoreNum:ftObject = eng.CreateText(font1,"#"+y,eng.canvasWidth/4+50,80 + (eng.canvasHeight/20)*y)
    txtScoreNum.SetLayer(layerScore)
    
  5. Now, create a new text object for the score values. It is stored inside the txtHighScore array, which we have created earlier in the Creating a data structure section.
    txtHighScore[y-1] = eng.CreateText(font1,"0000000",(eng.canvasWidth/4)*3-50,80 + (eng.canvasHeight/20)*y,2)
    txtHighScore[y-1].SetLayer(layerScore)
    
  6. Close the FOR loop, set the layer to be inactive, and close the method.
    Next
    layerScore.SetActive(False)
    Return 0
    End
    

What just happened?

This method is a good example where you use local objects which you will never access individually in the game and also the use of global objects. These global objects are required when you want to change them later on, and need direct access to them.

Rocks rocks rocks—fill the space with some comets

The next two methods will be typical helper methods. The first one, CreateComet, is to create and set up a single comet at a given position. The second one, SpawnComets, will be used to spawn several large comets randomly over the total canvas space.

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

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