Interaction between physical objects is prescribed by means of bit masks. A mask that belongs to.
Every physics body in a scene can be assigned to up to 32 different categories, each corresponding to a bit in the bit mask. You define the mask values used in your game. In conjunction with the collisionBitMask and contactTestBitMask properties, you define which physics bodies interact with each other and when your game is notified of these interactions.
(Swift) – contact categoryBitMask.
var contactBody1: SKPhysicsBody
var contactBody2: SKPhysicsBody
if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask{ contactBody1 = contact.bodyA contactBody2 = contact.bodyB } else{ contactBody1 = contact.bodyB contactBody2 = contact.bodyA }