title: Check if player is on top of another node?
body: <p>I'm trying to allow my player to jump. However I cannot let him jump in mid-air so I need to check if it's standing on top of another node before applying an impulse. </p>
  
  <p>How do other sprite-kit games normally do this?</p>
  
  <hr>
  
  <p>Right now I'm trying two approaches, the first one is this one. It's great however I don't know how to tell if the node the player is touching is really below or to the side of the player.</p>
  
  <pre><code>override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
      var allowJump = false
      let bodies = player.physicsBody.allContactedBodies()
      for body : AnyObject in bodies {
          if let node = body.node {
              allowJump = true // Player is touching another node but we don't know where (the bottom of the player or it's sides)
          }
      }
  }
  </code></pre>
  
  <p>This is the other approach, it's effective to tell if a contact started and also whether the contact is really with the ground (below the player) and not a wall or such. However I don't know how to tell when the player stops being on top of any nodes, because even if a contact ends he might still be contacting another node.</p>
  
  <pre><code>func didBeginContact(contact: SKPhysicsContact!){
      if(contact.bodyA.node.position.y &lt; contact.contactPoint.y) {
          println("BodyA is on top of another node")
      }
  
      if(contact.bodyB.node.position.y &lt; contact.contactPoint.y) {
          println("BodyB is on top of another node")
      }
  }
  
  func didEndContact(contact: SKPhysicsContact!){
       if(contact.bodyA.node.position.y &lt; contact.contactPoint.y) {
          println("BodyA is on no longer on top of BodyB")
      }
  
      if(contact.bodyB.node.position.y &lt; contact.contactPoint.y) {
          println("BodyB is no longer on top of BodyA")
      }
  }
  </code></pre>