April 2021
Beginner to intermediate
506 pages
11h 57m
English
At the moment, Val and the monsters who hunt her don’t take on any damage when hit. The reason this is happening is because the GameScene+PhysicsContact.swift file isn’t set up to handle the contacts between the player and the monsters or the monsters and the projectiles.
Switch to the GameScene+PhysicsContact.swift file, and inside of the switch statement (above the line that reads // MARK: - Projectile | Collectible), add the following code:
| | // MARK: - Player | Monster |
| | |
| | case PhysicsBody.player.categoryBitMask | |
| | PhysicsBody.monster.categoryBitMask: |
| | let playerNode = contact.bodyA.categoryBitMask == |
| | PhysicsBody.player.categoryBitMask ? |
| | contact.bodyA.node : contact.bodyB.node ... |
Read now
Unlock full access