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

Inside the OnObjectTouch method of the engine class, we want to start a new game when the PLAY or RESET button are hit. If the EXIT button was hit, we want to end the game. And if an atom element got hit, we want to start a chain reaction.

  1. Insert a Select statement with a call to the object's GetTag method.
    Class engine Extends ftEngine
    Method OnObjectTouch:Int(obj:ftObject, touchId:Int)
    Select obj.GetTag()
    
  2. Add a Case statement with the game's grpAtom constant. This identifies an atom element.
    Case g.grpAtom
    
  3. Now, check if this object already has a transition going on.
    If obj.GetTransitionCount() = 0 Then
    
  4. Create a new rotation transition by relative 90 degrees to its current angle and with a transition ...

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