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 — acting on layer update events

In the OnUpdateLayer method, we want to update emitters and enemies. Also we want to check whether all tiles were removed and start the next level. If all lives of the player's ball are gone, we want to display the Game Over text. Follow the given steps:

  1. Let's add a check to see if the layer parameter of the method is equal to layerGame.
    Method OnLayerUpdate:Int(layer:ftLayer)
    If layer = g.layerGame Then
    
  2. Now, do a FOR EACHIN loop of the emitter list of the game class:
    For Local emitter := Eachin g.emitterList
    
  3. Check whether a call to the emitter's Update method returns FALSE. We will use the engine's current delta time as a parameter for the emitter's Update call. If it is, then the emitter is done ...

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