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 is updated as follows:

  1. First add two FLOAT variables at the start which will store the difference factor regarding objects positions.
    Method OnObjectTouch:Int(obj:ftObject, touchId:Int)
    Local xdiff:Float
    Local ydiff:Float
    
  2. Check if game mode is equal to the constant g.gmMenu.
    If g.gameMode = g.gmMenu Then
    
  3. Start the Select statement on the object's Tag property.
    Select obj.GetTag()
    
  4. Check against the constant g.btnPlay (the play button). If yes, then start a new game.
    Case g.btnPlay
    g.StartNewGame()
    
  5. Check against the constant g.btnScore (the score button). If yes, then show the high-score screen.
    Case g.btnScore
    g.ShowScore
    
  6. Check against the constant g.btnExit (the exit button). ...

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