SpriteKit: why a node in a collision has a bitmask of category 4294967295 when this category was never bound to node

In the didBegin function didBegin one of the nodes has a bitmask of category 4294967295. However, this category is never assigned to any node.

Below are all used bit masks:

 struct PhysicsCategory { static let None : UInt32 = 0 static let All : UInt32 = UInt32.max static let Player : UInt32 = 0b1 // 1 static let WorldBorder : UInt32 = 0b10 // 2 static let TopWorldBorder : UInt32 = 0b100 // 4 static let RightWorldBorder : UInt32 = 0b1000 // 8 static let Pellet : UInt32 = 0b10000 } 

I repeat, the category All , which corresponds to 4294967295, is never assigned to any node. So why is there a physical body with this bit mask? Is this category bitmask never implicitly assigned to a physical body?

 func didBegin(_ contact: SKPhysicsContact) { print("Collision was detected: \(contact.bodyA.categoryBitMask). \(contact.bodyB.categoryBitMask).") } 
+6
source share
1 answer

categoryBitMask is UInt32 , and its maximum value is 4294967295 , which is also the default value (all bits are set). Quote from docs :

Each physical body in the scene can be assigned up to 32 different categories, each of which corresponds to a bit in the bitmask. You determine the mask values ​​used in your game. In combination with the collisionBitMask and contactTestBitMask properties, you determine which physical bodies interact with each other and when your game is notified of these interactions.

The default value is 0xFFFFFFFF (all bits are set).

+7
source

Source: https://habr.com/ru/post/1012712/


All Articles