问题
I setup an SKSprite (s1) to have physicsBody with polygon from path:
s1.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:path];
and the other one (s2) has physicsBody generated from its surrounding rectangle:
s2.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:e.size];
and the collisions of the two sprites are fine, they only happen when the actual pixels from the s1's polygon path and surrounding rectangle from the s2 collide (and not the surrounding rectangles from each of the sprites). This is fine. But the touchesMoved in the s1 - which has polygon based body - occurs when its surrounding rectangle is touched - even though it has the polygon based physicsBody (see above code for setting the physicsBody of s1). How can I solve this problem and have this event only fire when it should, which is when actual pixels (defined by the polygon based physicsBody) are touched?
I tried detecting the body at point:
SKPhysicsBody * draggedOverBody = [self.physicsWorld bodyAtPoint:location];
draggedOverNode = draggedOverBody.node;
and also it only detects the bounding rectangle instead of the polkygon physicsBody. Very frustrating.
来源:https://stackoverflow.com/questions/35692087/why-does-collision-work-properly-for-convex-polygon-based-physicsbody-but-touche