Collision filter

I’ m making a remake of qbasic gorillas.

My problem is:

I have two gorillas at the sides of the screen, who are standing on the physical object buildings.

The sun in the sky is also a physical object, such as the banana.

The banana and the sun have two associated event listener collision.

When the banana touches the opponent gorilla or buildings, it explodes.

The listener associated with the sun when it hits the banana has to change image in a smiling sun, but the banana has to continue on his way.

I’ve tried using the filter collisions, or by becoming the sun a sensor, but I can not make it work. I thought I could solve collisions with the filter, but apparently I can not. 

I would like banana listener would not notice the collision, while the sun listener yes. It possible? How?

With the collision filter should be,

having two bodies A and B, with a collision listener for each one , exclude the collision of A and B in A listener but activate the collision of A and B in B listener. B is a sensor, his listener change an image value when A pass through him, but the A listener must be activate only when A hit a C object.

Sorry for bad english.

Hello @marcoguerrera84,

In your description, the sun doesn’t need a collision listener… only the banana. This is because it’s the “main object” which might collide with other things (the sun, gorillas, buildings). So, I suggest this:

  1. Assign a local collision listener to the banana.

  2. Assign some naming property to every object, so you can read which is involved in a collision. For example, the banana might be “object.myName = ‘banana’”, the sun might be “object.myName = ‘sun’”, etc.

  3. Make the sun into a sensor object.

  4. Use the worksheet in the guide to calculate the correct collision filter values for all objects.

http://docs.coronalabs.com/guide/physics/collisionDetection/index.html

  1. When a collision occurs on the banana, use the “myName” property to detect what happens. For example, if the banana collides with the sun, the value of “event.other.myName” will be “sun”, and you can perform the necessary action.

Hope this helps,

Brent

It works like a charm, thank you !

P.S:

A note about the collision filter. 

From what I understand, the collision filter is not indispensable in the solution that you gave me. 

Additionally, the filter can not be different for the two objects. 

In the sense that I can not make that A collides with B and B does not collide with A. 

Thus I have to set the table in a way that A collides with B and B collides with A if I want the normal collision between the two objects.

It would be helpful if you changed it to use it in the way I had imagined, it would be much more useful.

Hello @marcoguerrera84,

In your description, the sun doesn’t need a collision listener… only the banana. This is because it’s the “main object” which might collide with other things (the sun, gorillas, buildings). So, I suggest this:

  1. Assign a local collision listener to the banana.

  2. Assign some naming property to every object, so you can read which is involved in a collision. For example, the banana might be “object.myName = ‘banana’”, the sun might be “object.myName = ‘sun’”, etc.

  3. Make the sun into a sensor object.

  4. Use the worksheet in the guide to calculate the correct collision filter values for all objects.

http://docs.coronalabs.com/guide/physics/collisionDetection/index.html

  1. When a collision occurs on the banana, use the “myName” property to detect what happens. For example, if the banana collides with the sun, the value of “event.other.myName” will be “sun”, and you can perform the necessary action.

Hope this helps,

Brent

It works like a charm, thank you !

P.S:

A note about the collision filter. 

From what I understand, the collision filter is not indispensable in the solution that you gave me. 

Additionally, the filter can not be different for the two objects. 

In the sense that I can not make that A collides with B and B does not collide with A. 

Thus I have to set the table in a way that A collides with B and B collides with A if I want the normal collision between the two objects.

It would be helpful if you changed it to use it in the way I had imagined, it would be much more useful.