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
  • PrintPrint
Share this Page URL
Help

5. Game #4, Chain Reaction > Time for action — detailing the OnObjectTransition...

Time for action — detailing the OnObjectTransition method

Time for action — detailing the OnObjectTransition method We will use this method to fire a timer that will switch the ID of an object. The ID is important for our collision checks. As we don't want to check the collision right away, we use a timer for a little delay: Inside the OnObjectTransition method, create an object timer with the game's tmObjSwitch constants. It should fire in 100 milliseconds: Method OnObjectTransition:Int(transId:Int, obj:ftObject) g.eng.CreateObjTimer(obj, g.tmObjSwitch, 100) Return 0 End What just happened? Since we don't want to check for collisions of the atom elements' connectors right away, we fire an object timer to do this with a little delay. It's about time—timer events Whenever a timer event fires, you want to act on it. If you don't, then it makes no sense to fire it in the first place, or does it?

  

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


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint