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 collision detection

The problem in this game is that sometimes it will report collisions of objects that are still in action, basically, when they pass by each other. For this, we check if the ID of the object's parent is bigger than the one of the second object's parent. If yes, the second object will start a transition.

  1. Inside the method OnObjectCollision, check if the collision group is equal to g.grpCircle.
    Method OnObjectCollision:Int(obj:ftObject, obj2:ftObject)
    If obj.collGroup = g.grpCircle Then
    
  2. Now, check whether the ID of the first parent obj is bigger than the second one and also that the second parent ID is positive. Negative ones are still in transition.
    If (obj.GetParent().GetID() > obj2.GetParent().GetID()) ...

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