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 — creating collision circles

The next method, CreateColCircle, will create an object that is used for collision checks only and will not be visible.

  1. To create the collision circles, insert a new method named CreateColCircles into the game class. The parameters are the parent object and the position of the circle.
    Method CreateColCircle:Int (parent:ftObject, xp:Float, yp:Float)
    
  2. Now, add a local circle object via CreateCircle, with a radius of 1.5 pixels.
    Local colObj:ftObject = eng.CreateCircle(1.5,xp, yp)
    
  3. Set the layer to layerGame and the parent to parent.
    colObj.SetLayer(layerGame)
    colObj.SetParent(parent)
    
  4. Now, set the collision group and with whom to collide with to grpCircle.
    colObj.SetColGroup(grpCircle) colObj.SetColWith(grpCircle,True) ...

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