基于Box2D的文档和教程在网上查到(最好的一个在这里http://www.iforce2d.net/b2dtut/collision-anatomy)我认为碰撞事件处理beginContact应该每次碰撞仅出现一次。Box2D的碰撞beginContant occurrs不止一次
但我的经验是,在某些情况下(我不能缩小这个下降到什么特别的事至今)beginContact被调用一次以上。
具体例子:
1st fixture is a box, belongs to static body and is a sensor
2nd fixture (which is also player body in 2d game I'm building)
is a polygon, belongs to dynamic body and is not a sensor.
Both are large enough so in debug mode it is absolutely clear
when these fixtures start to overlap and when they part.
Result is - while player body fixture passes through static sensor,
beginContact is called 3-4 times or more while fixtures keep oveplapping.
Velocity is moderate (fixtures keep overlapping for a whole second and more).
我怀念在文档中的东西吗?有没有办法解决这个问题?
是的,这两个是唯一在场的灯具 - 他们是球员和奖金挂在空中。我发现,这个问题涉及到fixtureShape - 我用ChainShape得到鬼顶点advantge(顺便说一句感谢这些伟大的教程),这似乎可每每个链节beginContact。我已经将简单的PolygonShape夹具添加到玩家身上,并且需要使用斧子 - 每次碰撞开始接触呼叫。 – Lez77 2014-09-06 13:16:58