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 — detailing the OnLayerUpdate method

The OnLayerUpdate method has the layer as a parameter.

  1. Check if the layer is equal to g.layerGame.
    Method OnLayerUpdate:Int(layer:ftLayer)
    If layer = g.layerGame Then
    
  2. Check if g.lifes are equal to or below 0.
    If g.lifes <= 0 Then 'GameOVER
    
  3. Set gameMode to g.gmGameOver.
    g.gameMode = g.gmGameOver
    
  4. Activate the layer g.layerTitle.
    g.layerTitle.SetActive(True)
    
  5. Add g.score to the high score list of the engine.
    g.eng.scoreList.AddScore(g.score,"---")
    
  6. Deactivate the player object.
    g.player.SetActive(False)
    
  7. Remove all particle objects and all remaining comets using their ID values.
    g.layerFX.RemoveAllObjects()
    layer.RemoveAllObjectsByID(g.grpComet)
    
  8. Save the high score list via g.SaveHighScore. Then Return

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