All the tutorials I look I see the number as 0x0 when is assigned to a UInt32
self.physicsBody!.collisionBitMask = 0x0
why not
self.physicsBody!.collisionBitMask = 0
is there a reason for it or just for readability ?
There is no difference between 0
and 0x0
, but it's written that way because the property in question is a bit mask, which can be easier to look at in hex. Probably elsewhere, other values will be written as 0x0010
and such, so they've chosen to write 0x0
for consistency's sake. It's a personal preference, so in your own code, feel free to use hex, binary, or even the bit shift operator (1 << 3
)—whatever helps you understand the constants and the way they interact as bit masks.