O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required