Nowhere can I find the answer, I am registering interactions between objects:

Player.physicsBody?.categoryBitMask = PhysicsCategory.Player Player.physicsBody?.collisionBitMask = PhysicsCategory.Border | PhysicsCategory.All | PhysicsCategory.Bod1 

In collisionBitMask I have a lot of objects, I try to replace these lines with one variable:

 mask = PhysicsCategory.Border | PhysicsCategory.All | PhysicsCategory.Bod1 Player.physicsBody?.collisionBitMask = mask 

What type should be a variable mask?

    1 answer 1

    Well, firstly, in the Swift language, you can write without explicitly specifying the type, because the type is thus derived automatically based on the context, for example:

     let mask = PhysicsCategory.Border | PhysicsCategory.All | PhysicsCategory.Bod1 Player.physicsBody?.collisionBitMask = mask 

    And secondly, the member-given categoryBitMask of the SKPhysicsBody class is SKPhysicsBody idea of ​​the type UInt32 , so you can specify this type and explicitly:

     let mask: UInt32 = PhysicsCategory.Border | PhysicsCategory.All | PhysicsCategory.Bod1 Player.physicsBody?.collisionBitMask = mask