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 object timer events

To act on timer events, fantomEngine provides the OnObjectTimer method in the engine class. We need to modify it.

  1. Modify the OnObjectTimer method in the engine class by adding a Select statement on timerId.
    Method OnObjectTimer:Int(timerId:Int, obj:ftObject)
    Select timerId
    
  2. Check for the constant g.tmShowMenu. Here, we deal with the automatic switch from the title screen to the menu screen.
    Case g.tmShowMenu
    
  3. Check if the game mode is g.gmTitle, and then activate the menu layer.
    If g.gameMode = g.gmTitle Then
    g.gameMode = g.gmMenu
    g.ActivateLayer(g.gameMode)
    Endif
    
  4. Check for the constant g.tmObjRemove. Here, we deal with deleting the particle objects. After that, close the Select statement.
    Case g.tmObjRemove ...

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