SKPhysicsJoint: Contacts and collisions not working

谁说我不能喝 提交于 2020-01-15 07:36:25

问题


On IOS7.1, using SpriteKit, I've created two simple rectangular sprites with corresponding physics bodies. I set up contact and collision bit masks, and all works exactly as I expect: contacts are detected and collisions prevent the two rectangles from overlapping. But when I create an SKPhysicsJointSpring object and join the two rectangles, no contacts are ever detected even though the rectangles sometimes overlap during simulation. (The spring behavior works just as one would expect, though, with visible oscillations.)

In other words, joining physics bodies seems to prevent contact detection and collisions in SprikeKit, which is not the behavior I desire.

Anyone know of any way to fix this? Thanks.


回答1:


There is no fix, this is built-in behavior of the Box2D physics engine Sprite Kit uses. When you connect two bodies through a joint, they no longer contact and do not collide with each other.

With Box2D you can change this behavior via the collideConnected flag. However no such flag exists in Sprite Kit's physics classes.



来源:https://stackoverflow.com/questions/22599434/skphysicsjoint-contacts-and-collisions-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!