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 — 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:

  1. 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 ...

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