How to make ball bounce vertically only and not horizontally using SKSpriteKit?
<p>I am making an iOS application in which I only want the ball to bounce up &amp; down, not horizontally or by any other angle. Unfortunately, the way I decided to design the game led to some problems down the road. Here is a GIF that kind of shows what my problem is: </p>

<p><a href="https://i.stack.imgur.com/OAYyH.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OAYyH.gif" alt="enter image description here"></a></p>

<p>Basically: sometimes when I click to rotate the pentagon, it hits the ball at an angle when I only want it going up and down.</p>

<p>Here is my code for the ball:</p>

<pre><code>func createBallNode(ballColor: String) -&gt; SKSpriteNode {
    let ball = SKSpriteNode(imageNamed: ballColor)
    ball.position = CGPoint(x: CGRectGetMidX(frame), y: CGRectGetMidY(frame)+1)

    ball.physicsBody = SKPhysicsBody(circleOfRadius: 25)
    ball.physicsBody?.affectedByGravity = true
    ball.physicsBody?.restitution = 0.99
    ball.physicsBody?.linearDamping = 0
    ball.physicsBody?.friction = 0

    ball.physicsBody?.categoryBitMask = ColliderType.Ball.rawValue
    ball.physicsBody?.contactTestBitMask = ColliderType.Rect.rawValue
    ball.physicsBody?.collisionBitMask = ColliderType.Rect.rawValue

    return ball
}
</code></pre>

<p>Is there anyway I can design the ball to always move in a certain line (vertically)? Does anyone have design suggestions for the ball, or maybe a different way of moving it (SKActions, ex: moveTo rather than using gravity).</p>

<p>Let me know. Thanks!</p>