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 OnLayerTransition method

For this, we need to detail the OnLayerTransition method of the engine class, as follows:

  1. First, we check if the transition ID is equal to g.tidNextLevel.
    Method OnLayerTransition:Int(transId:Int, obj:ftLayer)
    If transId = g.tidNextLevel Then
    
  2. Then, reset the alpha value of the layer back to 1.0. That means it would be fully visible.
    g.layerGame.SetAlpha(1.0)
    
  3. Next, check whether the current level number is smaller than 4 (we have only four levels).
    If g.levelNum < 4 Then
    
  4. Raise the current level number and load a new level.
    g.levelNum+=1
    g.LoadLevel()
    
  5. Switch the game mode back to g.gmPlay.
    g.gameMode = g.gmPlay
    
  6. If the last level is already reached, activate the title layer.
    Else g.layerTitle.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