I've created 2 nodes but when they contact nothing happens, here's the code:
private var circle:Circle?
circle?.name = "Ball"
circle?.physicsBody?.isDynamic = true
circle?.physicsBody?.categoryBitMask = 1
circle?.physicsBody!.contactTestBitMask = 2
self.addChild(Circle(radius: 100 , position: location ))
let obstacle = SKSpriteNode(color: UIColor.white, size : CGSize(width: 0, height : 30))
obstacle.name = "OBSTACLE"
obstacle.physicsBody?.isDynamic = true
obstacle.position = CGPoint( x : 0 ,y : self.size.height + obstacle.size.height )
obstacle.physicsBody = SKPhysicsBody.init(rectangleOf: obstacle.size)
obstacle.physicsBody?.isDynamic = true
obstacle.physicsBody?.categoryBitMask = 2
self.addChild(obstacle)
func didBegin(_ contact: SKPhysicsContact) {
if contact.bodyA.node?.name == "Ball" {
print(" something ")
}
}
The two nodes are implemented to the view but when they contact I don't get the " something ".
I don't know what's wrong with the contact test bitmask.