# How to detect collision on specific part of the sprite node

I have a spike and a ball is falling down, when the ball touches the top point of the spike, I want to make the ball invisible, and when it touches on the other part i.e on the sides I don't want to make it invisible.

I have two sprite nodes - Ball and spike.

How can I make the collision detect only on specific part i.e only on top of the spike in spritekit?

• I'm not familiar with spritekit, but can't you just test collision with a point at the top of the spike, instead of the full spike? – Sergio Jul 16 '14 at 16:47
• @Sergio. That is what i want to know, how to detect collision only on the point of the spike node. The spike is the complete node, so when i detect collision it happens with the complete spike. – user654987 Jul 16 '14 at 17:09

Remember that SpriteKit's physics system is based on "SKPhysicsBody"s, which are added to "SKSpriteNode"s. Those physics bodies, however, needn't be attached to visible nodes.

The simplest method is to create a SpriteNode with no actual sprite or visible body, add it as a child to the area you want on the visible shape, and categorize it differently from the visible body.

In your specific case, create a tiny node, add it to the "Triangle", position it at the top, and treat it as a separate category with a different contact behavior for the "Circle". In that contact method, you define the unique contact behavior you desire (whether you want to lower the alpha, set the alpha to 0, remove the "Circle" from the scene, or any other form of "invisibility" appropriate to your situation).

I'm just learning SpriteKit myself, however I think the following would be faster:

- (BOOL)checkCollisionForSpikePoint:(GCPoint)spikePoint
ballCenter:(CGPoint)ballCenter