class GameScene: SKScene {
let player = SKSpriteNode(imageNamed: "spaceship")
struct PhysicsCategories {
static let None: UInt32 = 1
static let Player: UInt32 = 0b1
static let Obsticles: UInt32 = 0b10
static let Diamond: UInt32 = 0b100
}
func didBegin(_ contact: SKPhysicsContact) {
var body1 = SKPhysicsBody()
var body2 = SKPhysicsBody()
if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask {
body1 = contact.bodyA
body2 = contact.bodyB
}
else {
body1 = contact.bodyB
body2 = contact.bodyA
}
if body1.categoryBitMask == PhysicsCategories.Player && body2.categoryBitMask == PhysicsCategories.Obsticles {
body1.node?.removeFromParent()
body2.node?.removeFromParent()
}
}
I want to remove the diamond once it come in contact with the player and also the player when it comes in contact with the obstacle. Currently im unable to register the contact between any of them Im currently using Xcode version 9.4.1. Will the problem stay if I update the app to