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 activate layer method

The next method will activate/deactivate layers, depending on the game mode we give in as the parameter.

  1. Add a new method called ActivateLayer to the game class. As a parameter, it will take the game mode as an INT value.
    Method ActivateLayer:Int(mode:Int)
    Deactivate ALL layers.
    layerBackground.SetActive(False)
    layerGame.SetActive(False)
    layerGFX.SetActive(False)
    layerGameOver.SetActive(False)
    layerMenu.SetActive(False)
    layerScore.SetActive(False)
    layerTitle.SetActive(False)
    
  2. Start a Select statement with the variable mode as the expression.
    Select mode
    
  3. Check against the gmPlay constant. If it's true, activate the background, game, and GFX layers.
    Case gmPlay layerBackground.SetActive(True) layerGame.SetActive(True) ...

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