September 2018
Intermediate to advanced
434 pages
8h 47m
English
Now that we have the physics categories, we need to go back through our existing game objects and assign the categories to the physics bodies. We will start with the Player class.
Open Player.swift and add the following code at the bottom of the init function:
self.physicsBody?.categoryBitMask =
PhysicsCategory.penguin.rawValue
self.physicsBody?.contactTestBitMask =
PhysicsCategory.enemy.rawValue |
PhysicsCategory.ground.rawValue |
PhysicsCategory.powerup.rawValue |
PhysicsCategory.coin.rawValue
self.physicsBody?.collisionBitMask =
PhysicsCategory.ground.rawValue We assigned the penguin physics category to the Player physics body, and used the contactTestBitMask property to set up contact logic tests ...
Read now
Unlock full access