I am trying to create a game where the user plays by shooting balls. I want the balls to bounce off the top border and the side borders. The ball is initially placed at the bottom border, and when the user touches a spot, the ball goes in that direction and bounces off the borders. However, I want the ball to stop once it touches the bottom border again rather than bouncing off of it. I've made it so that the ball bounces off all the border, but I'd like it to only bounce off the top and the sides. My apologies if this code isn't enough for the proper response; I'm relatively new at this forum :)
let border = SKPhysicsBody(edgeLoopFrom: self.frame)
//create variable representing frame of gamescene
border.friction = 0
border.restitution = 1
self.physicsBody = border
This is the code for the collision detection. func didBegin(_ contact: SKPhysicsContact) {
if (contact.bodyA.categoryBitMask == BodyType.ball.rawValue && contact.bodyB.categoryBitMask == BodyType.BottomBorder.rawValue){
SmallBall.isPaused = true
}
else if(contact.bodyB.categoryBitMask == BodyType.ball.rawValue && contact.bodyA.categoryBitMask == BodyType.BottomBorder.rawValue)
{
SmallBall.isPaused = true
}
}
}