title: Make SKSpriteNode character move with SKSpriteNode platform
body: <p>I'm building a platform game that has an SKSpriteNode character who jumps onto moving platforms.</p>
  
  <p>When the platform moves the character doesn't and it ends up falling off the platform. If I tap the move button the character moves along nicely, but I want the character to 'stick' to the platform as it moves.</p>
  
  <p>I haven't posted code as the code is working as expected. I have a feeling its a property that I can set?</p>
  
  <p>EDIT:</p>
  
  <p>I have a solution - just not sure it's how people should do it so I'll post below and wait for feedback. It's long and complex and probably doesn't need to be.</p>
  
  <p>When the user presses the left or right directional button I move the scene from GameScene.swift by:</p>
  
  <pre><code>    func moveGround(direction: String) {
  
  
      if direction == "left" {
  
          [snip...]
          // move the platforms
          self.enumerateChildNodesWithName("platform") {
              node, stop in
  
              if let foundNode = node as? PlatformSprite {
                  node.position.x += Helper().kMovingDistance
              }
  
          }
  
          // move all other nodes
          self.enumerateChildNodesWithName("*") {
              node, stop in
  
              if let foundNode = node as? SKSpriteNode {
                  node.position.x += Helper().kMovingDistance
              }
  
          }
          [snip...]
  
      } else if direction == "right" {
  
          [snip...]
          // move the platforms
          self.enumerateChildNodesWithName("platform") {
              node, stop in
  
              if let foundNode = node as? PlatformSprite {
                  node.position.x -= Helper().kMovingDistance
              }
  
          }
  
          // move all other nodes
          self.enumerateChildNodesWithName("*") {
              node, stop in
  
              if let foundNode = node as? SKSpriteNode {
                  node.position.x -= Helper().kMovingDistance
              }
  
          }
          [snip...]
      }
  </code></pre>
  
  <p>This moves the scene along nicely. Then when the character lands on top of a platform I initiate the platform movements using SKAction sequence AND initiate the scene movements by sending the reverse sequence to GameScene:</p>
  
  <pre><code>    func startMoving() {
  
      if !self.isMoving {
  
          [snip...]
  
          // get the platform actions and initiate the movements
          let actions = self.getMovements()
          let seq:SKAction = SKAction.sequence(actions)
  
          // move the platform
          self.runAction(seq, completion: { () -&gt; Void in
              self.completedPlatformActions()
          })
  
          // get the reverse actions and initiate then on the scene / ground
          let reverseActions = self.getReverseMovements()
          let reverseSeq:SKAction = SKAction.sequence(reverseActions)
  
          delegate!.moveGroundWithPlatform(reverseSeq)
  
          self.isMoving = true
  
      }
  }
  </code></pre>
  
  <p>Then I have a function for moving the ground with a platform and add a key to the runAction so I can stop just that action and not the platforms actions if the user ceases to be in contact with the platform:</p>
  
  <pre><code>   func moveGroundWithPlatform(seq: SKAction) {
  
      [snip...]
  
      self.enumerateChildNodesWithName("platform") {
          node, stop in
  
          if let foundNode = node as? PlatformSprite {
              node.runAction(seq, withKey: "groundSeq")
          }
  
      }
    [snip...]
    }
  </code></pre>
  
  <p>Then I stop moving the scene, but let the remaining actions of the platform continue using:</p>
  
  <pre><code>    func stopMovingGroundWithPlatform() {
  
      [snip...]
      self.enumerateChildNodesWithName("platform") {
          node, stop in
  
          if let foundNode = node as? PlatformSprite {
              node.removeActionForKey("groundSeq")
          }
  
      }
      [snip...]
  }
  </code></pre>
  
  <p>Ugly I know - if others have suggestions about how better to do this I'd love to know :)</p>