Time for action — creating the menu screen

In the menu screen we create, the game title will also be displayed at the top.

  1. Insert a new method called CreateMenuScreen into the game class.
    Method CreateMenuScreen:Int()
    
  2. Set the the default layer to layerMenu.
    eng.SetDefaultLayer(layerMenu)
    
  3. Add a dark-gray-colored box that covers the whole canvas.
    Local b := eng.CreateBox(cw,ch,cw/2,ch/2)
    b.SetColor(55,55,55)
    
  4. Now, add a text object that will display the game title and scale it by a factor of 2.
    Local t1 := eng.CreateText(font1, strTitle, cw/2, ch/2-100, 3)
    t1.SetScale(2.0)
    
  5. Now, add three text buttons. We need the buttons Play, Score, and Exit.
    Local bt1 := CreateTextButton(font1, "Play", cw/2, (ch/9)*4, btnPlay, layerMenu)
    Local bt3 := CreateTextButton(font1, "Score", cw/2, (ch/9)*5, btnScore, layerMenu)
    Local bt6 := CreateTextButton(font1, "Exit", cw/2, (ch/9)*7, btnExit, layerMenu)
    Close of this method.
    Return 0
    End
    

What just happened?

To set up the menu screen, you just need to call the method once in the OnCreate event of the game. If you need more menu entries, just add them here. The menu screen will look like the following screenshot of the game:

What just happened?

What is the score?… creating the high-score screen

What is a good game without the ability to display the highest scores you have reached while playing. For this, we will implement a screen that displays the high scores.

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

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