Chapter 10 Collision Mask

Hi,
Why in Chapter 10, Collision Mask for Ball we set to -1 value and not to 0 or 1?

@chrislanguage Can you please help with this when you get a chance? Thank you - much appreciated! :]

0 or 1 won’t work. What you could put is 2 + 4 + 8 = 14, the category mask values for barrier, brick, and paddle added together.

However -1 is stored in binary as all 1s, and is the default value for collisionBitMask on a dynamic body. From the documentation: " The default value is 0xFFFFFFFF (all bits set)." This means the ball will collide with all bodies having category > 0, which is what you want in this case.

Thank you. Now I understand

This topic was automatically closed after 166 days. New replies are no longer allowed.