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
    obj.Remove()
    End
    Return 0
    End
    

What just happened?

The OnObjectTimer method will take care of the title screen's switch to the menu screen and the removing of particles.

Touch me—acting on Touch checks

The text objects in the menu and the score screen and also the gems in the grid are touchable and we make touch checks in various places in the game. To act on this, you need to modify the OnObjectTouch method in the engine class.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.139.162