Physics category masks

You can assign physics categories to each physics body in your game. These categories allow you to specify the bodies that should collide, the bodies that should be in direct contact, and the bodies that should pass through each other without any event. When two bodies try to share the same space, the physics simulation will compare each body's categories and test whether collision or contact events should fire.

Our game will include physics categories for the penguin, the ground, the coins, and the enemies.

Physics categories are stored as 32-bit masks, which allows the physics simulation to perform these tests with processor-efficient bitwise operations. It is not strictly necessary to understand bitwise operations to use ...

Get Swift Game Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.