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 physics categories, but it is a nice topic for further reading, if you are interested in enhancing your knowledge. If you are interested, try an internet search for Swift bitwise operations.
Each physics body has three properties you can use to control...