Inside the OnObjectCollision
method, we will remove tiles, and the ball, and will spawn some particle effects:
1. Check whether the collision group of
obj2
is equal togrpEnemy
. That means the ball collided with the enemy:Method OnObjectCollision:Int(obj1:ftObject, obj2:ftObject) If obj2.GetColGroup() = g.grpEnemy Then
2. Remove
obj1
, the ball:obj1.Remove()
3. Spawn a new particle emitter at the ball's position, with a time factor of
300
milliseconds and akind
flag of1:
g.SpawnEmitter(obj1.GetPosX(), obj1.GetPosY(), 300,1)
4. Play the explosion sound effect:
g.sndExplo.Play()
5. Now, reduce the
lifes
variable of thegame
class:g.lifes -= 1
6. And create a new ball:
g.CreateBall() Endif
This was the check against enemy collisions. Now, we handle the tile set.
7. Check whether the collision group of
obj2
is equal togrpTile:
If obj2.GetColGroup() = g.grpTile Then
We will do a very simple collision resolution. This means we will determine...