title: Creating a contact listener when sprites from different classes meet
body: <p>I want to create a contact listener in such a way that I'll be able to create a joint when sprites from different classes meet. I found a useful question and answer which has helped me - <a href="https://stackoverflow.com/questions/10866715/getting-the-worlds-contactlistener-in-box2d/10901407#10901407">Getting the world's contactListener in Box2D</a> partly. The following code and insrtuctions where recommended:</p>
  
  <pre><code>std::vector&lt; std::pair&lt;b2Fixture*, b2Fixture*&gt; &gt; thingsThatTouched;
  
  //in BeginContact
  thingsThatTouched.push_back( make_pair(contact-&gt;GetFixtureA(), contact-&gt;GetFixtureB()) );
  
  //after the time step
      for (int i = 0; i &lt; thingsThatTouched.size(); i++) {
      b2Fixture* fixtureA = thingsThatTouched[i].first;
      b2Fixture* fixtureB = thingsThatTouched[i].second;
  // ... do something clever ...
  }
  thingsThatTouched.clear(); //important!!
  </code></pre>
  
  <p><em>For this to work you'll need to make the thingsThatTouched list visible from the contact listener function, so it could either be a global variable, or you could set a pointer to it in the contact listener class, or maybe have a global function that returns a pointer to the list.</em></p>
  
  <p>I am using Cocos2d and don't know much C++. How can I <em>"make the thingsThatTouched list visible from the contact listener function"</em> in Cocos2d?  Should </p>
  
  <pre><code>std::vector&lt; std::pair&lt;b2Fixture*, b2Fixture*&gt; &gt; thingsThatTouched;
  </code></pre>
  
  <p>be in the ContactListener.h file? How will it differ in Cocos2d? Thanks.</p>