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

In this method, make use of the CreateAtomElements method that we have built before:

  1. In the game class, add a new method called StartNewGame.
    Method StartNewGame:Int()
    
  2. First, set the game score to 0.
    score = 0
    
  3. Next, deactivate the title layer. Because of this, it won't be rendered and doesn't act on touch hits from the user.
    layerTitle.SetActive(False)
    
  4. Now, remove all objects from the game layer (if there are any).
    layerGame.RemoveAllObjects()
    
  5. Set the collCount field to 0. This will be used as an increasing ID for collision checks.
    collCount = 0
    
  6. Finally, call the method that will create the grids of atom elements.
    CreateAtomElements()
    
  7. The last step is to set the game mode to gmPlay and close this method: ...

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