title: Jumping with Sprite Kit and Swift
body: <p>I am creating an app in Sprite Kit and Swift and want to create a sprite that jumps upwards while the screen is pressed, therefore jumping higher as the screen is pressed higher.  I have achieved that effect, but gravity in the physics engine is not being applied until after the screen is released.  Therefore the jumps are infinite (increasing exponentially) rather than levelling off at a certain point (like a quadratic equation / parabola).</p>
  
  <p>How does one apply gravity actively during the motion of a sprite?</p>
  
  <p>Here is my basic movement code:</p>
  
  <pre><code>override func update(_ currentTime: TimeInterval) {
      // Called before each frame is rendered
      // touched is true while screen is touched
      if touched {
          nodeLeft.physicsBody?.applyImpulse(CGVector(dx: -5, dy: 0))
      }
   }
  </code></pre>
  
  <p>NOTE: The object is jumping right and left rather than up and down</p>