问题
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