I have these four circles that are moving from the bottom of the screen to the top. I have another circle in the middle of the screen. The circle in the middle can move to the left and right by touching either the left or right side of the screen. I want the score to increment by one every time the circle in the middle of the screen dodges one of the other 4 circles that are coming up. How would I accomplish this? Thanks. This is the code I have that is not working for what I want it to do.
// This function is called on contact between physics objects
func didBeginContact(contact:SKPhysicsContact){
let node1:SKNode = contact.bodyB.node!
let node2:SKNode = contact.bodyB.node!
if primaryBall == contact.bodyA.node! {
primaryBall.physicsBody?.affectedByGravity = true
view?.scene?.paused = false
} else {
primaryBall.physicsBody?.affectedByGravity = false
}
if ballToDodge.size.height > -50 + primaryBall.size.height {
self.score++
highscoreLabel.text = String(score)
}
}
override func update(currentTime: CFTimeInterval) {
if ballToDodge.position.y < enemy.position.y {
self.score++
highscoreLabel.text = String(score)
}
}