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)
    
  5. Since you don't want to see each circle, you set it to be invisible and then close the method.
    colObj.SetVisible(False)
    Return 0
    End
    

What just happened?

By creating invisible collision objects, we can automize the collision detection later on. We don't have to check at which angle an atom will be, because the circles will spin with their parent atom element.

Atom elements

To create the actual atom elements we will use another method.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.104.248