It looks like you're new here. If you want to get involved, click one of these buttons!
Scene = gideros.class(Sprite) function Scene:init() ... world:addEventListener(Event.BEGIN_CONTACT, self.onBeginContact, self) ... function Scene:onBeginContact(event) local fixtureA = event.fixtureA local fixtureB = event.fixtureB local bodyA = fixtureA:getBody() local bodyB = fixtureB:getBody() --print("begin contact: "..bodyA.name.." "..bodyB.name) -- only make a sound if both objects have sound if bodyA.sound and bodyB.sound then bodyA.sound:play() end end |
Likes: fxone
Comments
One other option can be using Event.POST_SOLVE and check for event.maxImpulse > some_constant:
I'll try the POST_SOLVE approach next. I'll report back with the results ...
Chip
Also you may not play sounds with e.g. volume < 0.1.