The OnObjectCollision
method has two parameters. The first object is the one that actually checks against a collision with the second object. To identify an object, we will compare against its collision group field, collGroup
.
1. Add a local integer variable called
i
to theOnObjectCollision
method.Method OnObjectCollision:Int(obj:ftObject, obj2:ftObject) Local i:Int
2. Now, check if the
collGroup
field of the second object isg.grpComet
. As this is a constant from thegame
class, we need to add the prefixg
. which stores it.If obj2.collGroup = g.grpComet Then
3. Compare the
tag
field with the constant comet sizeg.cmLarge
.If obj2.tag = g.cmLarge Then
4. Spawn an explosion of
15
particles viag.SpawnExplosion
at the position of the first object.g.SpawnExplosion(15,obj.xPos, obj.yPos)
5. Now, create two new comets of the size
g.cmMiddle
.For i = 1 To 2 g.CreateComet(g.cmMiddle,obj2.xPos, obj2.yPos, Rnd(1,4)/2,Rnd(0,359)) Next
6. Add
100
...