Physics category struct in Sprite Kit

260 Views Asked by At

I have been making a game using Sprite Kit and its physics and met this struct in tutorial:

struct PhysicsCategory
{
    static let None: UInt32 = 0
    static let All: UInt32 = UInt32.max
    static let Player: UInt32 = 0b10
    static let Obstacle: UInt32 = 0b11
}

Can anyone tell me what means 0b01 etc. and how to make a new constant here?

1

There are 1 best solutions below

0
On BEST ANSWER

It's hexa, that is, a 16-base number

0b11 in hexa is

0 * 16^3 + 11 * 16^2 + 1 * 16^1 + 1 * 16^0 = 2816 + 16 + 1 = 2833

In hexa, numbers like 10, 11, 12, 13, 14, 15 are represented by letters, such as a, b, c, d, e, f

Look here for more info.