基本的Box2D碰撞检测


9

我不明白如何在Cocos2D / Box2D中侦听碰撞。假设我有两个动态的圆形物体。一个很小,另一个很大。当小圆圈与大圆圈碰撞时,我想做点事(例如播放声音)。最好的方法是什么?

我目前正在尝试使用TestPoint方法。就像是:

if(largeCircleBody->GetFixtureList()->TestPoint(smallCirclePoint)){
    // collision happened...
    // play sound etc
}

Answers:


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.