Collisions and Trajectories
The character may throw a rock.
This rock way start from the character (x,y) and goes anywhere.
So, there is a first collision between the character and the rock at the very start.
There are also collisions between energies and the rock : energies are only sensors, they must not collide with the rock and stop it.
To cancel the physics linked to the very first collision or with sensors, I must use Corona “preCollision" and ‘event.contact.isEnabled = false’
if(event.other == character.sprite or event.other.isSensor) then
event.contact.isEnabled = false
Now I need the rock to collide to know when it’s crashed and to be removed from the playground.
Here, the collisions I’ve mentionned later will occur all the same. The pre-collision has just cancelled the “physics” to apply, but if I listen to collision, I will hear the character or a sensor collide with the rock.
So here again, I must check whether to accept or not the collision occuring
if(event.other ~= character.sprite and not event.other. isSensor) then
Thanks to this tutorial, I can draw the trajectory of my rock.