I'm doing a shooting game the problem i have so far is that when the bullet collides with the Enemy and call the function update score, they call the function around 10 times, heres my didBeginContact:
func didBeginContact(contact: SKPhysicsContact) {
var firstBody :SKPhysicsBody
var secondBody :SKPhysicsBody
if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask
{
firstBody = contact.bodyA
secondBody = contact.bodyB
}
else {
firstBody = contact.bodyB
secondBody = contact.bodyA
}
if (firstBody.categoryBitMask == CollisionCategories.Bullet) &&
(secondBody.categoryBitMask == CollisionCategories.Enemy) {
println("Hit")
firstBody.node!.removeFromParent()
secondBody.node!.removeFromParent()
//change score
updateScore(1)
}
}