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

5. Game #4, Chain Reaction > Time for action — acting on timer events

Time for action — acting on timer events

To act on timer events, we need to detail the OnObjectTimer method inside the engine class. We will set the ID of an object to positive once again, and then check for collisions of its child collision circles:

  1. Check whether timerID is equal to g.tmObjSwitch.
    Method OnObjectTimer:Int(timerId:Int, obj:ftObject)
    If timerId = g.tmObjSwitch Then
    
  2. Get the object's ID and store it locally in the id variable.
    Local id:Int = obj.GetID()
    
  3. If id is negative, set it back to positive.
    If id < 0 Then obj.SetID(obj.GetID()*-1)
    
  4. Start a For loop now, for every child collision circle of the object.
    For Local i:Int = 1 To obj.GetChildCount()
    
  5. Do a collision check for each collision circle.
    g.eng.CollisionCheck(obj.GetChild(i))
    

  

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