The category usage allows for exactly 16 categories and a sprite may be a member of any of them.
The categories themselves have no meaning, it is all in the way you use them.
For instance, you could assign all walls as categories 1 and 2, assign ghosts category 3, heroes category 1 and bad guys category 2.
Then you could use GetSpriteHitCategory with the value b0000000000000011 (3) to see if a hero or bad guy hit a wall. This would ignore hits between ghosts and walls because the ghosts are not the correct category.
The confusion comes with the commands because the SetSpriteCategoryBit uses the bit position as an input and the the SetSpriteCategoryBit
s and GetSpriteHitCategory use bit mask fields and they use hex values to display the examples in the documentation.
This table shows the hex and bit masks for the 16 categories:
hex mask - bit mask - category
0x0001 - b0000000000000001 - 1
0x0020 - b0000000000000010 - 2
0x0040 - b0000000000000100 - 3
0x0080 - b0000000000001000 - 4
0x0010 - b0000000000010000 - 5
0x0020 - b0000000000100000 - 6
0x0040 - b0000000001000000 - 7
0x0080 - b0000000010000000 - 8
0x0100 - b0000000100000000 - 9
0x0200 - b0000001000000000 - 10
0x0400 - b0000010000000000 - 11
0x0800 - b0000100000000000 - 12
0x1000 - b0001000000000000 - 13
0x2000 - b0010000000000000 - 14
0x4000 - b0100000000000000 - 15
0x8000 - b1000000000000000 - 16
To set or check multiple categories, you add the hex or bit mask values. To check for categories 1 and 2:
0x0001 + 0x0002 = 0x0003
b0000000000000001 = b0000000000000010 = b0000000000000011
In both cases above, if the values were being used as 'proper' numbers, the decimal value would be 3. But that is not how they are used in the Category commands. The commands use bit masks as shown above.
Maybe this helps clear it up a little bit.
Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master