I have to detect collision between two SKSpriteNode(wall, man) which is the child of a SKNode background. The background node is child of main SKScene gameScene class. When I want to detect collision using the method
- (void) didBeginContact:(SKPhysicsContact *)contact {
SKPhysicsBody *firstBody, *secondBody;
if (contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask)
{
firstBody = contact.bodyA;
secondBody = contact.bodyB;
}
else {
firstBody = contact.bodyB;
secondBody = contact.bodyA;
}
NSLog(@"contact happened");
}
But no collision detection is found. Please help.