It looks like you're new here. If you want to get involved, click one of these buttons!
function Game:collision(e) local fixtureA = e.fixtureA local fixtureB = e.fixtureB local bodyA = fixtureA:getBody() local bodyB = fixtureB:getBody() if bodyA.type == "gasoil" and bodyB.type == "copter" then Timer.delayedCall(1, function() bodyA.class:removeFromParent() bodyA:setActive(false) end) end end |
Comments
I had to add : fixture:setSensor(true) to my gasoil body (bodyA).
The Gobb : https://play.google.com/store/apps/details?id=fr.toastapp.thegobb
- Set filter for copter's main fixture so it won't collis with items
- Made another fixture for copter that collis with items, which isSensor
Could you explain how to use filter and sensor please ? I try but i didn't understand.
Of course i took a look to the Manual
The Gobb : https://play.google.com/store/apps/details?id=fr.toastapp.thegobb
Explanation is here :
http://docs.giderosmobile.com/reference/physics/b2Body/createFixture
If you set isSensor to true, like in that example, then the body would not calculate collision(like bounce, and friction) with the others.
[NB: Just for if you advanced enough later on, it also won't calculate event.contact, which mean you can't know where exactly the x and y collision happened]
Filter explanation is like this:
In this example if you apply it on filterUsed, then:
- fixture with charFilter will collis with char itself
- fixture with charItemFilter will collis with itemFilter
- fixture with itemFilter will collis with itself, and with charItemFilter
if you're got used with hex, you can use 0x0001 to 0xFFFF, because the maximum is 0xFFFF, which goes so long if turned as binary, )
There are also groupIndex for filter parameter, explanation here :
http://docs.giderosmobile.com/reference/physics/b2Fixture/setFilterData#b2.Fixture:setFilterData
The Gobb : https://play.google.com/store/apps/details?id=fr.toastapp.thegobb
http://giderosmobile.com/forum/discussion/1070/a-little-information-about-collision-filters#Item_1