9
\$\begingroup\$

I don't understand how to listen for collisions in Cocos2D/Box2D. Say I have two dynamic circle bodies. One is very small and the other is relatively large. When the small circle collides w/ the large circle I'd like to do something (play a sound for example). What's the best way to do this?

I'm currently experimenting w/ the TestPoint method. Something like:

if(largeCircleBody->GetFixtureList()->TestPoint(smallCirclePoint)){
    // collision happened...
    // play sound etc
}
\$\endgroup\$
9
\$\begingroup\$

You use b2ContactListener

http://www.box2d.org/manual.html#_Toc258082975

http://www.emanueleferonato.com/2008/12/23/understanding-how-box2d-manages-collisions/

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.