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 — enhancing the OnObjectTouch method

The OnObjectTouch method has the object itself as a parameter, and the touch ID that was given optionally when the TouchCheck statement was called.

  1. Inside the OnObjectTouch method, do a SELECT on the object's tag value.
    Method OnObjectTouch:Int(obj:ftObject, touchId:Int)
    Select obj.GetTag()
    
  2. Check against the constant btnPlay, that is, the Play button:
    Case g.btnPlay
    
  3. Play the Select sound and start a new game:
    g.sndSelect.Play()
    g.StartNewGame()
    
  4. Check against the btnBack constant. This is the Back button:
    Case g.btnBack
    
  5. Play the Select sound, activate the title layer, and set the game mode to gmMenu:
    g.sndSelect.Play()
    g.layerTitle.SetActive(True)
    g.gameMode = g.gmMenu
    
  6. Check against the btnExit constant. ...

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