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 a StartNewGame method

This method will deactivate the title layer, set the level number to 1, and load the level. To implement it, follow the ensuing steps:

  1. Insert the new method called StartNewGame into the game class.
    Method StartNewGame:Int()
    
  2. Deactivate the title layer.
    layerTitle.SetActive(False)
    
  3. Set the level number to 1 and load the level.
    levelNum = 1
    LoadLevel()
    
  4. The field gameMode needs to be set to gmPlay. Close this method.
    gameMode = gmPlay
    Return 0
    End
    

What just happened?

Our last helper method starts a new game. It set all corresponding fields and will load the first level map.

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