Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

9. Game #8, Treasure Chest > Time for action — enhancing the OnObjectTouch meth...

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). If yes, then exit the app.
    Case g.btnExit
    g.eng.ExitApp(True)
    

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial