Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i use void ContactListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold) method in our application?
    primarykey
    data
    text
    <p>I dont know how to use this metnod in my application </p> <pre><code>void MyContactListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold) { b2WorldManifold worldManifold; contact-&gt;GetWorldManifold(&amp;worldManifold); b2PointState state1[2], state2[2]; b2GetPointStates(state1, state2, oldManifold, contact-&gt;GetManifold()); //NSLog(@"Presolving"); if (state2[0] == b2_addState) { const b2Body* bodyA = contact-&gt;GetFixtureA()-&gt;GetBody(); const b2Body* bodyB = contact-&gt;GetFixtureB()-&gt;GetBody(); b2Vec2 point = worldManifold.points[0]; b2Vec2 vA = bodyA-&gt;GetLinearVelocityFromWorldPoint(point); b2Vec2 vB = bodyB-&gt;GetLinearVelocityFromWorldPoint(point); b2Vec2 rV = vB - vA; float32 approachVelocity = b2Dot(rV, worldManifold.normal); if (-1.5f &lt; approachVelocity &amp;&amp; approachVelocity &lt; 0.0f) { //MyPlayCollisionSound(); NSLog(@"Not Playing Sound"); } else { NSLog(@"playing the sound"); } } } </code></pre> <p>How can I use this code in my HelloWorldLayer.mm Please help me... I have a problem here, I have a scene where some bodies falls and hit a static body, edges alike, I implemented the b2ContactListener, and in my tick method Im checking for contacts and play the sound, the problem with this approach is that when a body is constantly in contact with the static body, the sound plays indefinitely overlaying the previous one, so at the end I have huge noise.. What can I do to avoid this situation?</p> <p>Please help me thanks......</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload